1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
#include <stdlib.h>
#include <string>
#include <iostream>
#include <vector>
using namespace std;
class Person
{
protected:
string name;
int ID;
string gender;
public:
Person(string name, int ID, string gender)
{
this-> name = name;
this-> ID = ID;
this-> gender = gender;
}
const string getName () const
{
return name;
}
const int getID () const
{
return ID;
}
const string getGender () const
{
return gender;
}
vector <string> children;
};
class Male: public Person
{
private:
vector <Person> wife;
};
class Female: public Person
{
private:
vector <Person> husband;
};
void displayAll (Person *arr[])
{
int SIZE = 10;
cout << "\nThe people in the system are...\n";
for(int i = 0; i < SIZE; i++)
{
cout << arr[i] -> getName << "\n"; //where error occurs
}
cout << "\n";
}
int main()
{
const int SIZE = 10;
Person *arr[SIZE];
arr [0] = new Person ("Abraham", 1, "M");
arr [1] = new Person ("Sarah", 2, "F");
arr [2] = new Person ("Keturah", 3, "F");
arr [3] = new Person ("Hager", 4, "F");
arr [4] = new Person ("Issac", 5, "M") ;
arr [5] = new Person ("Jokshan", 6, "M");
arr [6] = new Person ("Midian", 7, "M");
arr [7] = new Person ("Ishmael", 8, "M");
arr [8] = new Person ("Rebekah", 9, "F");
arr [9] = new Person ("Esau", 10, "M");
displayAll(arr);
return 0;
}
|