I have a class that is used to control the users input. In that class I have a function that looks like this
This function is called upon when a user asks to enter an Artists name. Now I want to make another function that displays what is inside that list. This is what I have so far...Code:void Controller::AddArtBandName() { string artName; cout << endl << "Enter the bands name: " << flush; cin >> artName; Artist *artist = new Artist(artName); list<Artist> myArtist; myArtist.push_back( *(new Artist(artName)) ); //Informs user what they just added cout << "\tAdded : " << artName << endl << endl ; }
When I call upon this function it does not display anything in the list. I am guessing that this is because the list is redefined in my DisplayArtName function. So with that said the only solution I can come up with is to declare the list global in my .h file, but I can't figure out how to do it. Any suggestion?Code:void Controller::DisplayArtName() { list<Artist> myArtist; cout << endl << "List of Artist: " << endl; list<Artist>::iterator iter; for(iter = myArtist.begin(); iter != myArtist.end(); iter++) cout << (*iter).getArtBandName() << endl; }
Thanks
Chad