help needed

I cannot figure out what is wrong with my code. Can someone help me please

#include <string>
#include <vector>
#include <iostream>

using namespace std;
class Person
{
public:
Person();
Person(string name, string address,string email, string telephone, string i);
string getname();
string getaddress();
string getemail();
string gettelephone();
string virtual whatami();
private:
string name;
string address;
string email;
string telephone;
string i;
};

class Student: public virtual Person
{
public:
Student(string status, string name, string address, string email, string telephone, string i);

string getstatus();
string virtual whatami();
private:
string status;
string i;
};

class Employee: public virtual Person
{
public:
Employee(string name, string address, string email, string telephone, string office, int salary, string date, string i);

string getoffice();
int getsalary();
string getdate();
virtual string whatami();

private:
string office;
int salary;
string date;
string i;
};

class Faculty: public virtual Employee
{
public:
Faculty(string name, string address, string email, string telephone, string office, int salary, string date, string rank,
string status, string i);

string getrank();
string getstatus();
virtual string whatami();

private:
string rank;
string status;
string i;

};
class Staff: public Employee
{
public:
Staff(string name,string address,string email, string telephone,string office,int salary,string date,string position, string i);

string getposition();
virtual string whatami();

private:
string position;
string i;


};
class StaffST: public Staff, public Student
{
public:
StaffST(string name,string address, string email, string telephone,string office,int salary,string date,string position,
string status, int credithours, string i);
int getcredithours();
virtual string whatami();
private:
int credithours;
string i;
};

Person::Person(string name, string address, string email, string telephone, string i)
{
this -> name = name;
this -> address = address;
this -> email = email;
this -> telephone = telephone;
this -> i = i;
}

Student::Student(string status, string name, string address, string email, string telephone, string i)
:Person( name, address,email, telephone, i)
{
this -> status = status;
this -> i = i;

}

Employee::Employee(string name,string address,string email,string telephone,string office,int salary,string date, string i)
:Person( name,address, email, telephone, i)
{
this -> office = office;
this -> salary = salary;
this -> date = date;
this -> i = i;
}

Faculty::Faculty(string name,string address,string email,string telephone,string office,int salary,string date,string rank,
string status, string i):Employee( name,address, email, telephone, office,salary,date,i),Person( name,address, email, telephone, i)
{
this -> rank = rank;
this -> status = status;
this -> i = i;
}

Staff::Staff(string name,string address,string email, string telephone,string office,int salary,string date,string position, string i)
:Employee( name,address, email, telephone, office,salary,date,i),Person( name,address, email, telephone, i)
{
this -> position = position;
this -> i = i;
}

StaffST::StaffST(string name,string address, string email, string telephone,string office,int salary,string date,string position,
string status, int credithours, string i):Staff( name, address, email, telephone, office,salary, date, position,i)
,Student(status,name,address,email, telephone,i),Person( name,address, email, telephone, i)

{
this -> credithours = credithours;
this -> i = i;
}

//Functions for Person
string Person::getname()
{
cout << "Enter the person's name: ";
return name;
}
string Person::getaddress()
{
cout << "Enter the person's address: ";
return address;
}
string Person::getemail()
{
cout << "Enter the person's email: ";
return email;
}
string Person::gettelephone()
{
cout << "Enter the person's telephone: ";
return telephone;
}
//Functions for student

string Student::getstatus()
{
return status;
}
string Student::whatami()
{
return i;
}

// Functions for Employee

string Employee::getoffice()
{
return office;
}
int Employee::getsalary()
{
return salary;
}
string Employee::getdate()
{
return date;
}
string Employee::whatami()
{
return i;
}
//Functions for Faculty
string Faculty::getrank()
{
return rank;
}
string Faculty::getstatus()
{
return status;
}
string Faculty::whatami()
{
return i;
}
// Funtions for Staff

string Staff::getposition()
{
return position;
}
string Staff::whatami()
{
return i;
}
int StaffST::getcredithours()
{
return credithours;
}
string StaffST::whatami()
{
return i;
}
int main()
{
string a,b,c, tel, i;

Person P = Person( a, b, c,tel, i);


cout << P.getname()<< endl;
getline(cin, a);
/*vector<Person*>v;
v.push_back(new Person("John Adams","Boston","617-555-0000","john@adams.com", "regular person"));
v.push_back(new Student("John Quincy Adams","Boston","617-555-0000","johnq@adams.com","senior", "student"));
v.push_back(new Staff("Samuel Adams","Boston","617-555-BEER","sam@adams.com","brewhouse 1",1000,"9-15-1764","Brewer","staff"));
v.push_back(new StaffST("Samuel Smith","Boston","617-555-BEER","samsmith@adams.com","brewhouse 5",100,"9-15-1774","Taster","junior",50, "staffSt"));

// Hey - no Faculty object ---> add one yourself!

for (int i=0; i<v.size(); i++)
{
cout << v.getname() << " " << v[i]-> whatami() << endl;
}*/

return 1;

}
Debbuger showed problems with whatami() function in class Person.I do not know if it's deffined
Last edited on
1) Please use code tags when posting code, to make it readable:

http://www.cplusplus.com/articles/z13hAqkS/

2)
I cannot figure out what is wrong with my code. Can someone help me please

What do you mean? If your compiler is showing error messages, then it helps if you tell us what the messages are.

3)
Zivojin wrote:
I do not know if it's deffined

Zivojin has found at least one problem. It isn't defined. Nowhere in your code do you define a Person::whatami() method.

Did you intend that method to be pure virtual? If so, you should declare it as such:

1
2
3
4
5
class Person
{
public:
  virtual string whatami() = 0;
};

Last edited on
Topic archived. No new replies allowed.