Whoa, you definitely have code that should be throwing warnings and/or errors. If your compiler isn't rejecting this then I'm very surprised.
Let's take a look at your main function:
Code:
int main(int argc, char *argv[])
{
//mynewList->Add();
cout<<"BEFORE: "<<endl;
ShowAll(*mynewList->GetList());
// There is no need to make this a pointer! It's ridiculous.
medList::iterator *it = &mynewList->GetList()->begin();
while( (*it) != mynewList->GetList()->end())
{
Results->push_back(&(**it));
(*it)++;
}
system("PAUSE"); // You really should #include <cstdlib> if you're going to use this...
medSearchResultList::iterator iterate = Results->begin();
while(iterate != Results->end())
{
// Whoa! Why are you using 'it' here!?
// Furthermore, you are trying to dereference the return value
// from a function that returns void!!!
*(*it)->SetName("FROM POINTER!");
// Oh jeez, you forgot to increment your iterator...
// Can you say infinite loop?
}
cout<<"MODIFIED THROUGH POINTER LIST CLASS"<<endl;
ShowAll(*mynewList->GetList());
system("PAUSE");
return(0);
}
Here's a slightly fixed up version:
Code:
int main(int argc, char *argv[])
{
//mynewList->Add();
cout<<"BEFORE: "<<endl;
ShowAll(*mynewList->GetList());
medList::iterator it = mynewList->GetList()->begin();
while (it != mynewList->GetList()->end())
{
Results->push_back(&*it);
it++;
}
system("PAUSE");
medSearchResultList::iterator iterate = Results->begin();
while(iterate != Results->end())
{
(*iterate)->SetName("FROM POINTER!");
iterate++;
}
cout<<"MODIFIED THROUGH POINTER LIST CLASS"<<endl;
ShowAll(*mynewList->GetList());
system("PAUSE");
return(0);
}
Your compiler is hopefully also throwing numerous warnings about how you are passing const char pointers into your constructors/functions and assigning them to non-const char pointers. This is very dangerous. You might be tempted to try modifying those internal strings at some point, at which time you will most likely experience crashes.
I understand that you're trying to learn about pointers, but your usage of them is pretty ridiculous at times, and in several places you would be better off not using pointers. I find this code very hard to follow.