Greetings,
Another ridiculous question. I highly doubt it is possible to do the following but I might as well ask first.
Is there a way for a member function to know which object called it?
Assume the following:
and then in the code we do:Code:class A { void DoSomething(); } class B { A* pA; void SetAPointer(A* p){pA = p}; } class C { A* pA; void SetAPointer(A* p){pA = p}; }
The question is, inside those two last calls, inside DoSomething() is it possible to know who called it? Perhaps some way of getting the pointer to the object calling it?Code:A my A; B myB; myB.SetAPointer(&A); C myC; myC.SetAPointer(&A); myB.pA->DoSomething(); myC.pA->DoSomething();
Thanks![]()




Reply With Quote