I have the following classes:
Main.cpp
Display* display_obj;
void display_wrapper()
{
display_obj->display();
}
void main(int argc, char **argv)
{
//...
State* s = new State(100);
glutReshapeFunc(reshape_wrapper);
display_obj->setState(s);
//...
}
Display.h
class Display
{
public:
Display(){}
~Display(){};
void display();
void setState(State*);
private:
State* state;
};
//...
void Display::setState(State* s)
{
state = s;
}
State.h
class State
{
public:
State(){};
State(int);
~State(){};
private:
GLint timer;
Floor floor;
};
State::State(int t)
{
timer = t;
FloorLogical floorLogical;
floor = floorLogical.createFloor();
}
When i run the code i get the following exception in the instruction:
state = s;
Exception: Unhandled exception at 0x00F96719 in project_name.exe: 0xC0000006: Access violation writing location 0x00000000.
What is wrong?
display_obj is not initialized. You need to initialize that variable before you can use it.
User contributions licensed under CC BY-SA 3.0