How can a class's memory-allocated address be determined from within the contructor?
- by Jim Fell
Is it possible to get the memory-allocated address of a newly instantiated class from within that class's constructor during execution of said constructor? I am developing a linked list wherein multiple classes have multiple pointers to like classes. Each time a new class instantiates, it needs to check its parent's list to make sure it is included.
If I try to do something like this:
MyClass() // contructor
{
extern MyClass * pParent;
for ( int i = 0; i < max; i++ )
{
pParent->rels[i] == &MyClass; // error
}
}
I get this error:
error C2275: 'namespace::MyClass' : illegal use of this type as an expression
Any thoughts or suggestions would be appreciated. Thanks.