Quote:I checked the constructor Button, and about half the time it's being set properly, and the other half of the time it's being set to NULL. At all times it errors. Obviously something's screwy, but I can't figure out what. The problems are both in the same code. Here it is:
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
// button header
class Menu;
typedef void (Menu::*MenuFunct)(void);
struct Position {
Position(unsigned x=0, unsigned y=0) : _x(x), _y(y) {}
unsigned _x, _y;
};
struct Area {
Area(unsigned w=0, unsigned h=0) : _w(w), _h(h) {}
unsigned _w, _h;
};
class Button {
public:
Button(std::string text, MenuFunct funct, Position pos, Area area);
private:
std::string _text;
MenuFunct _funct;
Position _pos;
Area _area;
};
// button implementation
Button::Button(std::string text, MenuFunct funct, Position pos, Area area) {
this->_text = text;
this->_funct = funct;
this->_pos = pos;
this->_area = area;
}
// menu implementation
void Menu::CreateMainMenu() {
buttons.push_back( new Button( "Host Game", &Menu::CreateHostMenu, Position(100, 100), Area(100, 20) ) );
}