When I am declaring a new member attribute in my game.cpp
class like this:
int test;
I have a stack smashing error which is really strange because without the new attribute my program is running fine.
I know my problem is probably somewhere else in my program and I will not copy my whole program but some help about how to make the message more explicit and maybe some advice about stack smashing debugging would be nice.
This is my game.cpp
class in case. Sorry if I am missing something important I am a beginner in c++. Thank you
My error:
* stack smashing detected *: terminated Aborted (core dumped)
Game.cpp
public:
std::vector<Ball> m_balls; //list of ball in the current game, in case ball split in 3 energy ball
std::vector<Vault> m_vaults; //list of vaults , in case we are in cooperative mode
std::vector<Wall> m_walls; // lists of walls
int test; //Stack smashing wtf
Sdl_o_surface m_bg; // image containing sprites
Sdl_o_window m_window; //window containing one or more games (for the moment 1 or 2)
int score = 0;
int m_current_level = 1;
int m_x1; // borders of the game
int m_x2;
int m_y1;
int m_y2;
//constructor
Game(int x1, int x2 , int y1, int y2, int mode, Sdl_o_surface s, Sdl_o_window w);
//methods
void initSolo();
void initCoop();
void refreshWindowAndObjects();
void startGame();
void updatePosition();
void wallsCollision(Ball &ball);
void borderCollision(Ball &ball);
void vaultCollision(Ball &ball);
Sdl_o_rectangle getTexturePosition(); //get texture position depending on current level
Sdl_o_rectangle getBorders();
void parseLevelText();
void updateVaultsPosition(int x, int y);
//wall section
void chooseWallType(char type);
void placeWall(char t);