CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    85

    Dynamic Global object question

    This is probably straight forward but I can't quite think of how to go about this....

    I have a dialog class ADlgClass that uses an object from ObjClass to hold std::lists full of data. I don't want to have a static ObjClass variable in my ADlgClass but I need to have many, many functions of ADlgCLass be able to manipulate data in ObjClass. I tried doing:

    PHP Code:
     ObjClass MyObj = new ObjClass
    in the ADLgCLass ctor and then destroy it when the OnExit is processed by the dialog I'm getting mucho errors... How do I implement ObjClass so the entire ADlgClass sees it? Am I just a confused newbie??

    Thanks

  2. #2
    Join Date
    Feb 2004
    Location
    Portland, OR
    Posts
    13
    I'm not sure what you mean by mucho errors. But, I am assuming that you declared MyObj as a ptr member in your ADlgClass.

    If so, after you instantiate the object (new ObjClass), you should be able to reference it.

    class ADlgClass: public ....
    {
    private:
    ObjClass * m_MyObj;
    ...
    };

    ADlgClass::ADlgClass()
    {
    m_MyObj = new ObjClass;

    m_MyObj->myfield ...
    }
    Andrew Ferlitsch

  3. #3
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    85
    Originally posted by aferlitsch
    I'm not sure what you mean by mucho errors. But, I am assuming that you declared MyObj as a ptr member in your ADlgClass.

    If so, after you instantiate the object (new ObjClass), you should be able to reference it.

    class ADlgClass: public ....
    {
    private:
    ObjClass * m_MyObj;
    ...
    };

    ADlgClass::ADlgClass()
    {
    m_MyObj = new ObjClass;

    m_MyObj->myfield ...

    }

    OMG! Thanks for the reply. I think I see my error... I never declared a ptr to the ObjClass in my ADlgCLass code like this:
    PHP Code:
     Class ADlgClass: public ....
    {
    private: 
    ObjClass m_MyObj
    ...that could be a problem eh? THanks for pointing out my problem!

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