   Error C2440
  I've been trying to fix this problem for a few hours and I'm getting nowhere as I've tried all sorts of things. I've looked it up for a while but I can't find anything relating to this or how I can fix it. The problem I'm getting is this error:Error1error C2440: '=' : cannot convert from 'std::vector<_Ty>' to 'GameState *'on the following line of code:currentState = gameStates[newState]; (newState is a variable to an enum called States which will act as a number).Here is the code of the two pointers in the class file:vector<GameState> * gameStates;GameState * currentState;The vector is used to store GameState objects only and I'm trying to pass it to the current state. I've tried converting it but that hasn't worked either I'm out of ideas. Any help would be much appreciated.   
  If you want that code to compile you can use &((*gameStates)[newState]). Whether or not that's actually what you want may be another story.   ;Quote:Original post by SiCraneIf you want that code to compile you can use &((*gameStates)[newState]). Whether or not that's actually what you want may be another story.I get an error: Unhandled exception at 0x002f27b4. It's pointing to this code snippet:iterator end(){// return iterator for end of mutable sequencereturn (iterator(this->_Mylast, this));}   ;  Mentioning what kind of exception occurred would be helpful information. In any case, you're probably using an uninitialized or otherwise invalid pointer value.   ;  The error says Access violation reading location 0xcdcdcdd5. All I've done is given it one object of the type GameState: currentScreen->AddState(gameScreen); in a different class file. The AddState() method has this line of code: gameStates->insert(gameStates->end(), newState); where new state will be gameScreen.EDIT: Actually I should say gameScreen is not of the type GameState it's a type of GameScreen which inherits from GameState   ;  Are you sure you wantvector<GameState> * gameStates;and notvector<GameState *> gameStates;Right now you have a pointer-to-vector-of-gamestates.You seem to want a vector-of-pointers-to-gamestates.Right now, if you store a "gameScreen" in your vector, it will "slice" the class down to a GameState instead of providing the inheritance you'd get by storing pointers.;  The bit pattern 0xCDCDCDCD is one used by the MSVC debug runtime to indicate heap allocated memory that hasn't been initialized. See bit patterns.;Quote:Original post by KulSeranAre you sure you wantvector<GameState> * gameStates;and notvector<GameState *> gameStates;Right now you have a pointer-to-vector-of-gamestates.You seem to want a vector-of-pointers-to-gamestates.Right now, if you store a "gameScreen" in your vector, it will "slice" the class down to a GameState instead of providing the inheritance you'd get by storing pointers.Possibly, I'm still a complete newbie when it comes to pointers and I'm still trying to understand them. Your way returns a similar error but slightly different:Error1error C2440: 'initializing' : cannot convert from 'GameState' to 'GameState *';  How about: why do you even have pointers?   ;Quote:Original post by oler1sHow about: why do you even have pointers?Because it's holding a type of itself which hasn't been defined yet