Archived

This topic is now archived and is closed to further replies.

Object sending it's own address?

This topic is 5433 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok... I''m missing something really bloody simple here. I have a class object that needs to send it''s own pointer address as a parameter to a function from another class. How would I write that? Dave Mark - President and Lead Designer Intrinsic Algorithm - "Reducing the world to mathematical equations!"

Share this post


Link to post
Share on other sites
Right. Just be sure that you avoid circular references by using a forward reference in whichever of the classes makes sense to do so. In other words, in a class that can only use pointers, use

class CMyClass;

previous to your class declaration in CMyClass2. Then you can do an #include "MyClass.h" in CMyClass2.cpp, but you''re not allowed to use anything but pointers to CMyClass in CMyClass2 (CMyClass, which will be doing a #include "MyClass2.h" in the header, but will not require a "class CMyClass2;", will not have any such restrictions.

That way, you avoid getting undeclared errors everywhere, due to the fact that your classes apparently know about each other in some fashion.

-fel

Share this post


Link to post
Share on other sites