collection class using indexing

I need to write an entire class with a main method that       (using the 'next'  and  'hasNext'  functions)

 1 -  creates a collection of names called 'theNames'   (type string)

  2- prompts for and reads from the screen five values for 'theNames' and  adds  them into the collection without indexing.  It may require an appropriate value to teminate the data entry.

 3 - Prints the values back out without indexing
Who is Participating?
Jaime OlivaresSoftware ArchitectCommented:
you can use a list template:

using namespace std;
list<string> theNames;

to add values just use:

to iterate:
list<string>::iterator i;
for (i=theNames.begin(); i!=theNames.end(); i++) {
     // some operation with (*i), by example:
     cout << (*i) << endl;
usumleAuthor Commented:
good  good,   it runs fine ,  thanks
Jaime OlivaresSoftware ArchitectCommented:
Appear to be that you forgot to Accept the answer...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.