|
-
February 6th, 2004, 05:46 PM
#1
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
-
February 6th, 2004, 05:55 PM
#2
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
-
February 6th, 2004, 09:46 PM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|