Thread: vector and pointer - quickie

  1. #1
    Registered User
    Join Date
    Mar 2007

    vector and pointer - quickie

    Quick noob Q:

    This is how i get a draught for P1 and store it under d1 :

     Draught * d1 = player1->getDraught(i);
    Now once its gone through my checks i want to store it in my vector - the number of the draught that is, but i get errors saying :

    1: Cannot convert 'Draught *' to 'int' in function
    2: Error E2342 Game.cpp 231: Type mismatch in parameter 'x' (wanted 'const int &',
    got 'Draught *') in function Game::move(Square *,Draught *)


    i kno i ve made a noob mistake... any help??

  2. #2
    Registered User Noir's Avatar
    Join Date
    Mar 2007
    I say that your vector is a vector<int>, but you treat it like a vector<Draught*>. Maybe this? I don't know how your Draught works.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Looks like you are trying to store a Draught* in a vector<int>, so there is a type mismatch.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed