ok this time i try POO for my next project... i'm stuck with i think a very basic problem:
(using VC++)
this is myclassdef.h:
this is myclass.cpp
ok looks very simple staff
then myframegame.h where i want to declare an instance of my class:
then i try in the InitGameState()
compil & link ok, .exe generated
here is the probleme:
i get an ** access violation ** in the CEngine::Init() body on the line where i set: m_X = x; as if i had no rights to access m_X or m_Y :? in the debugger, i can see on m_X and m_Y: ** expression can't be evaluated **
what did i do ?!? did i miss a "xxxx.h" to load for this to work ? please help me to have my first class working :x
(using VC++)
this is myclassdef.h:
- Code:
class CEngine
{
public:
int m_X;
int m_Y;
CEngine();
~CEngine();
void Init(int x, int y );
};
this is myclass.cpp
- Code:
#include "myclassdef.h"
CEngine() // constructor
{
return NULL;
}
CEngine::~CEngine() // destructor
{
}
void CEngine::Init( int x, int y } // method Init
{
m_X = x; // <===== Stuck Here !
m_Y = y;
}
ok looks very simple staff
then myframegame.h where i want to declare an instance of my class:
- Code:
#include "Framegame.h"
#include "Factory.h"
#include "myclassdef.h"
using namespace Overloaded;
class mygame : public FrameGame
{
public:
void InitGameState();
void DoGameState();
private:
ScopedPtr<CEngine> myobject;
};
then i try in the InitGameState()
- Code:
myobject->Init( 120, 120 );
compil & link ok, .exe generated
here is the probleme:
i get an ** access violation ** in the CEngine::Init() body on the line where i set: m_X = x; as if i had no rights to access m_X or m_Y :? in the debugger, i can see on m_X and m_Y: ** expression can't be evaluated **
what did i do ?!? did i miss a "xxxx.h" to load for this to work ? please help me to have my first class working :x