Click to See Complete Forum and Search --> : instance address


piwiix
April 11th, 2003, 06:59 AM
I have to register a class (MyClass1) pointer in another class (MyClass2). MyClass2 needs to have this pointer to execute methods from MyClass1 later. The code below doesn't work because the 'this' pointer is const. So how can I obtain an address of MyClass1 instance pointer in MyClass2 ?

class MyClass1 : class MyMotherClass
{
...
protected:
void Init() {theApp.m_pMyClass2->Register(this);}
...
}

class MyClass2
{
...
public:
void Register(MyMotherClass *& pMyMotherClass);
...
}

Mike Harnad
April 11th, 2003, 07:58 AM
Try this instead:

class MyClass2
{
...
public:
void Register(MyClass1* pMyClass1);
...
}