If you're passing objects around from function to function, you may want to read up on references rather than pointers. A lot of the newer MFC classes now use references instead of pointers - they are a LOT easier to use and understand, especially for newer programmers.
In essence a reference is like an 'alias' of an object. You can pass a reference of an object/variable into a function and perform changes on it:
void SomeClass::SomeFunction()
{
int myInt = 7;
ChangeValue(myInt);
// value of myInt is now 12
// If we hadn't used a reference, myInt would still
// have the original value
}
void SomeClass::ChangeValue(int& intRef)
{
intRef += 5;
}
You will notice the ampersand "&" after the type declaration on ChangeValue()'s parameter. This means that the parameter is a reference to an int rather than an int. Therefore, any changes you make to the int in the function ChangeValue() are made to the original int in the calling function.
You can achieve the same by using pointers but it is not only harder to understand pointers, it also means that, for your custom objects, you usually have to have a copy constructor and overloaded assignment operator.
If you hadn't declared the parameter as a reference and simply left it as an int, the value in SomeFunction() would still be 7 for the int after it called ChangeValue()
All this being said, you do still need to learn about pointers because they are the heart and soul of C/C++ programming!! :-(
Going back to what I was saying earlier about C++ and object-oriented programming and classes being responsible for their own actions, etc. You should try and design your classes so they are 'self-contained' - that way, you can use the same code over and over again in any future programs without having to mess around with global variables and chopping and changing bits around to suit the new project.
As an example, I have just placed a 'TIP' message in this forum with a link to class library I have just written that extracts files from your application onto the user's hard disk at run time. The thread title is:
"Storing/extracting files from application's resources"
This is a classic example of how you can write a useful class which can simply be 'plugged' into any project. There's no need to worry about declaring global variables or anything like that, usually a class such as this will take variables/objects as parameters to perform the necessary work on them or perform useful stuff.
Using the OOP model saves programmers time and therefore money because they are using re-usable code and over again in their projects. I have made this library downloadable so that it will save programmers such as yourself the trouble of hard-coding the stuff yourself when you need a function that performs a particular utility. In other words, if the code is tried and tested and works, you don't need to tear your hair out trying to rewrite it and reinvent the wheel!