Hello and thanks again for all the previous help!
I'm trying to get a basic understanding of OOP before leveraging it to refactor some existing code. I'm off to a good start but am stuck on two things. My questions are in upper case in the comments of the code.
They are:
1) How to access the properties of CObjects stored in the CList
2) Is there a way to populate the CList with CObjects in an interative for() loop, or do I really have to create separate copies of the CObject for each?
Thanks!
Finally found an article that helped me figure out populating the list with a loop, so I guess I just need help with accessing the properties of objects retrieved with GetNodeAtIndex(). I did set the properties of the class to public.
CStatuses *oStatuses[2]; for(int i=0; i<2; i++) { oStatuses[i]=new CStatuses; oStatuses[i].TF=i; }
Finally found an article that helped me figure out populating the list with a loop, so I guess I just need help with accessing the properties of objects retrieved with GetNodeAtIndex(). I did set the properties of the class to public.
And the solution I found to accessing properties of objects retrieved from the list was in defining the variable that will hold them correctly rather than as creating a new object:
// This now works with the objects pre-defined this way: CStatuses currObj; CStatuses nextObj; currObj=statusCList.GetNodeAtIndex(0); nextObj=statusCList.GetNodeAtIndex(1); //CObject *currObj=statusCList.GetNodeAtIndex(0); //CObject *nextObj=statusCList.GetNodeAtIndex(1);

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
UPDATE: I FIGURED IT OUT -- so please don't spend time analyzing the code. Thank you! I posted my solutions below as replies (to myself LOL...)
Hello and thanks again for all the previous help!
I'm trying to get a basic understanding of OOP before leveraging it to refactor some existing code. I'm off to a good start but am stuck on two things. My questions are in upper case in the comments of the code.
They are:
1) How to access the properties of CObjects stored in the CList
2) Is there a way to populate the CList with CObjects in an interative for() loop, or do I really have to create separate copies of the CObject for each?
Thanks!