Quote:Original post by mikeman
Quote:
I wont need to delete them until the program exists, becuase it's a vector I use over and over again;
That's irrelevant; you must get used to delete everything you new,even if you do it in the end of the program,don't realy on the OS to clear the memory for you after the process exits. Or you can use boost's smart pointers that do it for you.
I know. I mentioned that I was glad he included it, though, because I'd still need to delete them later on.
I have another problem that hopefully someone can help me with:
I'm trying to move all of my sprites at the same time, similar to how MENTAL coded the drawing of each sprite. The only difference is, Sprites and Balls move differently; that is, Sprites don't move at all, and Balls bounce around. I came across virtual functions, and am under the impression that this is the best way to go with it.
For whatever reason though, when I declare them, I keep getting a compile error saying: "In Sprite.h: variable or field Move() declared void". Normally I'd expect this if I was trying to return something, but I'm not... Here's the sections in each class:
In Sprite.h
virtual void Move(vector<Sprite*> *gameSprites);
In Sprite.cpp
virtual void Sprite::Move(vector<Sprite*> *gameSprites)
{
// do nothing, return nothing.
}
In Ball.h
void Move(vector<Sprite*> *gameSprites);
In Ball.cpp
void Ball::Move(vector<Sprite*> *gameSprites)
{
// Do the stuff that moves a ball
// I don't return anything!
}
Everything looks A-ok to me... Any ideas?
Edit: It turns out it was a simple syntax error. I had forgotten to include "using namespace std;" in those two files. After adding the std:: to vector, everything worked fine. The compiler was just horribly confused =P
Meow.
[Edited by - KuroKitten on May 9, 2007 8:27:18 PM]