// p1 511 13-02-2003

 

#include <iostream>

#include <string>

 

class Person

{ protected:

    string name, address;

 

  public:

    Person(string n, string a)

     { name=n; address=a; }

   

    void print(void)

     { cout << "Person[name=" << name << ", address=" << address << "]\n"; } };

 

 

class Employee

{ protected:

    string name, address;

    int salary;

 

  public:

    Employee(string n, string a, int s)

     { name=n; address=a; salary=s; }

 

    void print(void)

     { cout << "Employee[name=" << name << ", address=" << address << ", salary=" << salary << "]\n"; } };

 

 

class Burglar

{ protected:

    string name, address, speciality;

 

  public:

    Burglar(string n, string s)

     { name=n; address="unknown"; speciality=s; }

 

    void print(void)

     { cout << "Burglar[name=" << name << ", address=" << address << ", speciality=" << speciality << "]\n"; } };

 

 

void main(void)

{ Person *people[10];

  Employee *workers[10];

  Burglar *criminals[10];

 

  workers[0] = new Employee("Joe Smith", "123 Ant Street", 34500);

  workers[1] = new Employee("Arthur Ant", "456 Smith Street", 45600);

  workers[2] = new Employee("Jill Jones", "1 Jones Street", 93000);

  workers[3] = new Employee("Sally Slug", "2 Jones Street", 81000);

 

  criminals[0] = new Burglar("Basher", "bludgeoning");

  criminals[1] = new Burglar("Fingers", "pickpocketing");

  criminals[2] = new Burglar("Frankie", "robbery");

 

  for (int i=0; i<4; i+=1)

    workers[i]->print();

 

  for (int i=0; i<3; i+=1)

    criminals[i]->print();

 

  cout << "All done\n"; }

 

--------------------------------------

Employee[name=Joe Smith, address=123 Ant Street, salary=34500]

Employee[name=Arthur Ant, address=456 Smith Street, salary=45600]

Employee[name=Jill Jones, address=1 Jones Street, salary=93000]

Employee[name=Sally Slug, address=2 Jones Street, salary=81000]

Burglar[name=Basher, address=unknown, speciality=bludgeoning]

Burglar[name=Fingers, address=unknown, speciality=pickpocketing]

Burglar[name=Frankie, address=unknown, speciality=robbery]

All done


// p2 511 13-02-2003

 

#include <iostream>

#include <string>

 

class Person

{ protected:

    string name, address;

 

  public:

    Person(string n, string a)

     { name=n; address=a; }

   

    void print(void)

     { cout << "Person[name=" << name << ", address=" << address << "]\n"; } };

 

 

class Employee: public Person

{ protected:

    int salary;

 

  public:

    Employee(string n, string a, int s): Person(n, a)

     { salary=s; }

 

    void print(void)

     { cout << "Employee[name=" << name << ", address=" << address << ", salary=" << salary << "]\n"; } };

 

 

class Burglar: public Person

{ protected:

    string speciality;

 

  public:

    Burglar(string n, string s): Person(n, "unknown")

     { speciality=s; }

 

    void print(void)

     { cout << "Burglar[name=" << name << ", address=" << address << ", speciality=" << speciality << "]\n"; } };

 

 

void main(void)

{ Person *people[10];

  Employee *workers[10];

  Burglar *criminals[10];

 

  workers[0] = new Employee("Joe Smith", "123 Ant Street", 34500);

  workers[1] = new Employee("Arthur Ant", "456 Smith Street", 45600);

  workers[2] = new Employee("Jill Jones", "1 Jones Street", 93000);

  workers[3] = new Employee("Sally Slug", "2 Jones Street", 81000);

 

  criminals[0] = new Burglar("Basher", "bludgeoning");

  criminals[1] = new Burglar("Fingers", "pickpocketing");

  criminals[2] = new Burglar("Frankie", "robbery");

 

  for (int i=0; i<4; i+=1)

    workers[i]->print();

 

  for (int i=0; i<3; i+=1)

    criminals[i]->print();

 

  cout << "All done\n"; }

 

--------------------------------------

Employee[name=Joe Smith, address=123 Ant Street, salary=34500]

Employee[name=Arthur Ant, address=456 Smith Street, salary=45600]

Employee[name=Jill Jones, address=1 Jones Street, salary=93000]

Employee[name=Sally Slug, address=2 Jones Street, salary=81000]

Burglar[name=Basher, address=unknown, speciality=bludgeoning]

Burglar[name=Fingers, address=unknown, speciality=pickpocketing]

Burglar[name=Frankie, address=unknown, speciality=robbery]

All done


// p3 511 13-02-2003

 

#include <iostream>

#include <string>

 

class Person

{ protected:

    string name, address;

 

  public:

    Person(string n, string a)

     { name=n; address=a; }

   

    void print(void)

     { cout << "Person[name=" << name << ", address=" << address << "]\n"; } };

 

 

class Employee: public Person

{ protected:

    int salary;

 

  public:

    Employee(string n, string a, int s): Person(n, a)

     { salary=s; }

 

    void print(void)

     { cout << "Employee[name=" << name << ", address=" << address << ", salary=" << salary << "]\n"; } };

 

 

class Burglar: public Person

{ protected:

    string speciality;

 

  public:

    Burglar(string n, string s): Person(n, "unknown")

     { speciality=s; }

 

    void print(void)

     { cout << "Burglar[name=" << name << ", address=" << address << ", speciality=" << speciality << "]\n"; } };

 

 

void main(void)

{ Person *people[10];

 

  people[0] = new Employee("Joe Smith", "123 Ant Street", 34500);

  people[1] = new Employee("Arthur Ant", "456 Smith Street", 45600);

  people[2] = new Employee("Jill Jones", "1 Jones Street", 93000);

  people[3] = new Employee("Sally Slug", "2 Jones Street", 81000);

  people[4] = new Burglar("Basher", "bludgeoning");

  people[5] = new Burglar("Fingers", "pickpocketing");

  people[6] = new Burglar("Frankie", "robbery");

 

  for (int i=0; i<7; i+=1)

    people[i]->print();

 

  cout << "All done\n"; }

 

--------------------------------------

Person[name=Joe Smith, address=123 Ant Street]

Person[name=Arthur Ant, address=456 Smith Street]

Person[name=Jill Jones, address=1 Jones Street]

Person[name=Sally Slug, address=2 Jones Street]

Person[name=Basher, address=unknown]

Person[name=Fingers, address=unknown]

Person[name=Frankie, address=unknown]

All done


// p4 511 13-02-2003

 

#include <iostream>

#include <string>

 

class Person

{ protected:

    string name, address;

 

  public:

    Person(string n, string a)

     { name=n; address=a; }

   

    virtual void print(void)

     { cout << "Person[name=" << name << ", address=" << address << "]\n"; } };

 

 

class Employee: public Person

{ protected:

    int salary;

 

  public:

    Employee(string n, string a, int s): Person(n, a)

     { salary=s; }

 

    virtual void print(void)

     { cout << "Employee[name=" << name << ", address=" << address << ", salary=" << salary << "]\n"; } };

 

 

class Burglar: public Person

{ protected:

    string speciality;

 

  public:

    Burglar(string n, string s): Person(n, "unknown")

     { speciality=s; }

 

    virtual void print(void)

     { cout << "Burglar[name=" << name << ", address=" << address << ", speciality=" << speciality << "]\n"; } };

 

 

void main(void)

{ Person *people[10];

 

  people[0] = new Employee("Joe Smith", "123 Ant Street", 34500);

  people[1] = new Employee("Arthur Ant", "456 Smith Street", 45600);

  people[2] = new Employee("Jill Jones", "1 Jones Street", 93000);

  people[3] = new Employee("Sally Slug", "2 Jones Street", 81000);

  people[4] = new Burglar("Basher", "bludgeoning");

  people[5] = new Burglar("Fingers", "pickpocketing");

  people[6] = new Burglar("Frankie", "robbery");

 

  for (int i=0; i<7; i+=1)

    people[i]->print();

 

  cout << "All done\n"; }

 

--------------------------------------

Employee[name=Joe Smith, address=123 Ant Street, salary=34500]

Employee[name=Arthur Ant, address=456 Smith Street, salary=45600]

Employee[name=Jill Jones, address=1 Jones Street, salary=93000]

Employee[name=Sally Slug, address=2 Jones Street, salary=81000]

Burglar[name=Basher, address=unknown, speciality=bludgeoning]

Burglar[name=Fingers, address=unknown, speciality=pickpocketing]

Burglar[name=Frankie, address=unknown, speciality=robbery]

All done