CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2003
    Posts
    74

    Question instance address

    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);
    ...
    }

  2. #2
    Join Date
    Apr 1999
    Posts
    3,585
    Try this instead:

    class MyClass2
    {
    ...
    public:
    void Register(MyClass1* pMyClass1);
    ...
    }
    Gort...Klaatu, Barada Nikto!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured