Solved hardcode these entries into main

October 26, 2011 at 06:36:49
C++ project help

I'm doing a rolodex project for a C++ course. I'm ready to test some code. I need help on how to hardcode the rolodex entries, so I don't have to type them each time.

"show(...) takes an ostream as a parameter, iterates through all the cards from beginning to end, invoking each card's show() method, and passing the ostream parameter. The Rolodex show() doesn't do any actual output - it just iterates through the collection and requests each card to display its contents by calling its show() member function. The current card remains unchanged."

my code
void Rolodex:: Show()
for ( iter = nCard.begin(); iter != nCard.end(); iter++ )

iter = nCard.begin();

void Card::displayCard(ostream &out)
out<<endl<<"First name = "<<first;
out<<endl<<"Last name = "<<last;
out<<endl<<"Address = "<<address;
out<<endl<<"Occupation = "<<occupation;
out<<endl<<"Phone Number = "<<phonenumber;

"'list' can call Rolodex::show(...) to display the entire rolodex"

"Use the following information to provide the initial information to demonstrate the
functionality of your rolodex program. You can hardcode these entries into your rolodex
initialization in main() to simulate reading the information from a file"

First Last Occupation Address Phone

Tony Hansen Writer 12 E. St. NY, NY 33333 555-9999

Jon Smyth Computer Hardware CMU 555-1324
Computer Services
Pittsburgh, PA

Alonza Heard Mechanic 123 Anyplace Ave 555-5678
Malden, MA

Jen Reyes Graphic artist 325 Oak Rd 555-4950
Wilmington, MA

See More: hardcode these entries into main

Report •

October 26, 2011 at 07:56:17
✔ Best Answer
Just create instances of Card objects, initializing them with the values given. Presumably you have defined a constructor for Card which performs that initialization.

Report •

October 26, 2011 at 09:47:01

Not sure why I was making it so hard on myself.

Report •

Related Solutions

Ask Question