c++ - Stack smashing when declaring new member attribute
问题描述
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);
解决方案
推荐阅读
- c# - 使用 SDK v4 与 Luis 服务的连接问题
- javascript - 如何从javascript中的字符串中获取最后一个数字
- reactjs - 如何在服务器(SSR)上持久化 redux 用户登录
- mediawiki - 更改 MediaWiki 的默认语言字符串
- javascript - 如何使用 Fetch API 从输入元素提交文件
- android - Android Studio 模拟器在 2018 年 11 月 13 日更新模拟器后不工作
- c# - C# JSON 返回对象
- html - 桌面版 Outlook 365 中带有 HTML 正文的自适应卡片垂直滚动条
- reactjs - 测试传递给 Redux HOC 的强制 PropType
- mysql - MySql - 从上次 X 点开始计算记录