Newsgroup: it.comp.lang.c++
Titolo: Linked List...

What's wrong with this program? I get an function call error...How to fix
this problem?
//======================================
 #include <iostream>
 #include <string>
 #include <cstdlib>
 using namespace std; //introduces namespace std
 class Person
 {
   friend class List;
   private:
      string firstName;
      string lastName;
      string age;
      Person* next;
   public:
      Person (string first = "Walan", string last = "Filand", string
age1="20");
      ~Person();
      void readPerson();
      void showPerson();
 };
 class List
 {
   private:
    Person* head;
   public:
    List();
    void insert(string first, string last, string age1);
    void print();
    bool isEmpty();
    ~List();
 };
 const int MAX = 5;
 int main ( void )
 {
   List myFriends;
   if (myFriends.isEmpty())
     cout << "Beginning: Just constructed an empty list." << endl;
   else
     cout << "Beginning: Error -  list should be empty." << endl;
   Person* personPtr;
   char choice = 'y';
   string endofline;
   while (choice != 'q')
   {
     cout << "Would you like to: "<< endl;
     cout << "a) add a person to the head of the list" << endl;
     cout << "p) print the entire list" << endl;
     cout << "q) quit the program" << endl;
     cout << "Your choice: ";
     cin >> choice;
     getline(cin, endofline);
     if (choice == 'a')
     {
       personPtr = new Person;
       personPtr ->readPerson();
       myFriends.insert(personPtr);
     }
     else if (choice == 'p')
     {
       cout << "Here's the current state of the list: " << endl;
       myFriends.print();
     }
   }
   if (myFriends.isEmpty())
     cout << "Ending: List is still empty." << endl;
   else
     cout << "Ending: List is not empty." << endl;
 }
 Person::Person(string first, string last, string age1)
 {
   firstName = first;
   lastName = last;
   age = age1;
   next = NULL;
 }
 Person::~Person()
 {
 }
 void Person::readPerson()
 {
   cout << "\nFirst Name?: " << endl;
   cin >> firstName;
   cout << "Last Name?: " << endl;
   cin >> lastName;
   cout << "Age? " << endl;
   cin >> age;
 }
 void Person::showPerson()
 {
   cout << "\nName: " << firstName << " " << lastName << " Age: " << age;
 }
 List::List()
 {
   head = NULL;
   cout << "List constructor called." << endl;
 }
 List::~List()
 {
   Person* togo;
   while (head != NULL)
   {
     togo = head;
     head = head ->next;
     delete togo;
   }
   cout << "List destructor called." << endl;
 }
 void List::insert(string first, string last, string age1)
 {
   Person* newPerson = new Person (first, last, age1);
   if(head == NULL)
     head = newPerson;
   else
   {
     head -> next = newPerson;
     head = newPerson;
   }
 }
 void List::print()
 {
   Person* temp = head;
   while (temp !=NULL)
   {
     temp ->showPerson();
     temp = temp ->next;
   }
 }
 bool List::isEmpty()
 {
   return head == NULL;
 }

This program can "run" now..but it didn't work. I think it is the problem of
the insert function...this program can run but it cannot insert a Person
object onto the head of the List and print the List...these are all I
want...please help
//===============
#include <iostream>
using namespace std; //introduces namespace std
class Person
{
  friend class List;
  private:
     string firstName;
     string lastName;
     string age;
     Person* next;
  public:
     Person (string first = "Walan", string last = "Filand", string
age1="20");
     ~Person();
     void readPerson();
     void showPerson();
};
class List
{
  private:
   Person* head;
  public:
   List();
   void insert(Person *head);









Person::~Person()
{
}




void List::insert(Person *head)
{
  Person* newPerson = new Person;
  newPerson -> next = head;
