I'm having a memory violation error and I don't know where it comes from. My question is : am I allowed to get the address of a class member while inside the constructor initialization list so that I can pass it to an object that needs a reference to it ?
For example :
class A
{
};
class ReferencesA
{
A * const pA;
ReferencesA( A * ptrA ) : pA( ptrA ) { }
};
class B
{
A a;
ReferencesA referencesA;
B() : referencesA( & a ) { }
};
Is is safe to & a
inside the constructor initialization list ? It seems to me that it would be, but things don't always work like we expect.
Thank you.