I've been trying to get a class to work, and even though I've worked with classes before, this time I have no clue as to what is going wrong.
This is my class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
class CCommander
{
public:
CCommander();
void move();
void arc();
void flyDown( int y_pos );
void exitScreen();
int x;
int y;
Surface* Graphic;
private:
int x_start;
int arcStage;
int arcDegrees;
};
You don't put the classname before the '.' operator... you put the object name.
However when you're inside the class, you don't need any qualifier before variable names because it assumes you're using 'this' as the object. Therefore you can just do this:
1 2 3 4 5 6 7
CCommander::CCommander()
{
arcDegrees = 0;
arcStage = 0;
Graphic = new Surface("assets/CCommander.tga"); // also, use '/' to separate directories.
x = 50;
}
Your help is very much appreciated, it's working now. TBH I already had several tries where I tried to declare an objectname for this class but it wouldn't work so I kept removing that.
Anyway, must've had been other problems that were causing that all.