Im getting the following error for the piece of code below : “expression list treated as compound expression” . I can’t find out whats wrong?
Shoot::Shoot() :
io( IOManager::getInstance() ),
count(0),
locX(0),
locY(0),
objWidth(0),
objHeight(0),
clock( Clock::getInstance() ),
ticks(0),
bulletSurface(io.loadAndSet("images/bullet.bmp", true)),
bulletFrame(bulletSurface, 30, 30, 0, 0),
thebullet(Vector2f(700,760), Vector2f(20,45), "bullet" , &bulletFrame)
{
}
DEclarations :
private :
const IOManager& io;
int count;
int locX;
int locY;
unsigned objWidth;
unsigned objHeight;
Clock& clock;
unsigned ticks;
SDL_Surface *bulletSurface;
Frame bulletFrame;
Sprite *thebullet;
Shoot(const Shoot&);
Shoot& operator=(const Shoot&);
The problem is that
thebulletis a pointer, but you’re trying to initialise it withVector2f(700,760), Vector2f(20,45), "bullet" , &bulletFrame.My guess is that you want
thebullet(new Bullet(...)).11. Although if it is, I strongly recommend that you don’t use raw pointers and manual memory management, and instead investigate smart pointers.