collection class using indexing

Posted on 2005-04-11
Medium Priority
Last Modified: 2010-04-17
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
Question by:usumle
  • 2
LVL 55

Accepted Solution

Jaime Olivares earned 340 total points
ID: 13759817
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;

Author Comment

ID: 13768740
good  good,   it runs fine ,  thanks
LVL 55

Expert Comment

by:Jaime Olivares
ID: 13784179
Appear to be that you forgot to Accept the answer...

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Six Sigma Control Plans
Screencast - Getting to Know the Pipeline

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question