Computer Science Canada Help with solitaire game |
Author: | zero-impact [ Fri Oct 02, 2009 8:41 pm ] | ||
Post subject: | Help with solitaire game | ||
OK so I am working on a project for my gr.12 cs class. The first part of the project is making a solitaire game playable by people. My problem is that my program is crashing for no apparent reason.
I have double checked that it is passing a valid pointer to the function. It just seems that the vector "cards" is not accepting anything. Also if I output cards.size() before push_back is called even once it outputs 8. I can supply more details upon request. Any help is appreciated ![]() Edit: This class represents the users mouse. The vector 'cards' holds the cards that the user is currently dragging from one stack to another. |
Author: | DtY [ Fri Oct 02, 2009 9:06 pm ] |
Post subject: | RE:Help with solitaire game |
Don't you have to do something to initialize a vector? (Or is that done automatically in c++?) |
Author: | zero-impact [ Fri Oct 02, 2009 9:53 pm ] |
Post subject: | RE:Help with solitaire game |
When I call cards.push_back(), it should dynamically allocate memory as far as I'm aware. I have a nearly identical set up for the other classes that contain a vector or stack of pointers to Card objects. |
Author: | saltpro15 [ Fri Oct 02, 2009 10:22 pm ] |
Post subject: | RE:Help with solitaire game |
I think you may have to specify a size for the vector. I've had similar problems before |
Author: | zero-impact [ Sat Oct 03, 2009 8:33 am ] |
Post subject: | RE:Help with solitaire game |
Already tried that, doesn't work. Not to mention it works perfectly fine in the other classes. |
Author: | zero-impact [ Sun Oct 04, 2009 1:53 pm ] |
Post subject: | Re: Help with solitaire game |
Found the problem and I hate myself for it... Forgot to add Mouse mouse; to one of my main header files >.< It was only in the .cpp file. |
Author: | saltpro15 [ Sun Oct 04, 2009 1:56 pm ] |
Post subject: | RE:Help with solitaire game |
*slow clap* |