Define a base class person that will contain universal information, including name, address, birth date, gender and identification (student, worker etc). Derive from this class the following classes:

Student

Worker

Student_worker

Add variable school to student and company to worker class.

Write a program that asks user to input information (student, worker etc) and creates a list of persons. Give user choice to view list by gender and by identification( list of people who are students, list of people who are workers etc).

THIS is what i got so far can some one help me finish it i need to turn this in today
thanks

#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

class person
{
  public:

  void input();
  void output() const;
person(string a, string b,string c,string d,string e, string f ); 
person::person()
{

    class student:person

    {
    string school;


    };

    class worker:person
    {
    string company;

    };

    class student_worker:worker,student

    {


    };
}

  private:
string name;
string gender;
string address;
string birthday;
string id;
};





person::person(string a, string b,string c,string d,string e, string f)
{
   name = a;
  gender= b;
  address=c;;
  birthday=d;;
  id=e;
}

//Set name and salary
void person::input()
{
  cout << "Entern name gender,address,bday: ";
  cin >> name >> gender>>address>>birthday>>id;
  cout<<"enter company or school or both"<<endl;


}

//output, should be "const" as it is not changing any variables
void person::output() const
{
  cout << "Name: " << name << endl << "gender: " << gender << endl<< address <<endl<< birthday<<id<<endl;
}




int main()
{
   person persons[5];


for (int i = 0; i < 5; ++i)
{
   persons[i] = person();
   persons[i].input();
   persons[i].output();




}
}

i need help with the code , they didnt go over inheritance that much in class

This article has been dead for over six months. Start a new discussion instead.