Question: C + + code. Why does my output not display the name, phone number, and email address? How can I fix it ? College student

C++ code. Why does my output not display the name, phone number, and email address? How can I fix it? College student is supposed to be subclass of Individual, Personell subclass of Individual, Faculty subclass of Personell, and Staff subclass of Personell. Do not make job position and title the same.
#include
#include
using namespace std;
class Individual
{
public:
Individual();
Individual(string Name, string PhoneNumb, string EmAddress);
virtual void to_string() const;
private:
string name;
string phoneNumb;
string emAddress;
};
Individual::Individual()
{
}
Individual::Individual(string Name, string PhoneNumb, string EmAddress)
{
string name = Name;
string phoneNumb = PhoneNumb;
string emAddress = EmAddress;
}
void Individual::to_string() const
{
cout " Individual named: " name " PhoneNumb: " phoneNumb " email Address: " emAddress;
}
// CollegeStudent class and functions
class CollegeStudent : public Individual
{
public:
CollegeStudent();
CollegeStudent(string Year, string Name, string PhoneNumb, string EmAddress);
virtual void to_string() const override;
private:
string year;
};
CollegeStudent::CollegeStudent()
{
}
CollegeStudent::CollegeStudent(string Year, string Name, string PhoneNumb, string EmAddress) : Individual(Name, PhoneNumb, EmAddress)
{
year = Year;
}
void CollegeStudent::to_string() const
{
Individual::to_string();
cout " year type: " year;
}
// Personnell class and functions
class Personnell : public Individual
{
public:
Personnell();
Personnell(int Income, string Name, string PhoneNumb, string EmAddress);
virtual void to_string() const override;
private:
int income =0;
//adds a Income
};
Personnell::Personnell()
{
}
Personnell::Personnell(int Income, string Name, string PhoneNumb, string EmAddress) : Individual(Name, PhoneNumb, EmAddress)
{
income = Income;
}
void Personnell::to_string() const
{
Individual::to_string();
cout " income: " income;
}
//Faculty class and functions
class Faculty : public Personnell
{
public:
Faculty();
Faculty(string Title, int Income, string Name, string PhoneNumb, string EmAddress);
virtual void to_string() const override;
private:
string title; //subclasses Personnell, adds a title
};
Faculty::Faculty()
{
}
Faculty::Faculty(string Title, int Income, string Name, string PhoneNumb, string EmAddress) : Personnell(Income, Name, PhoneNumb, EmAddress)
{
title = Title;
}
void Faculty::to_string() const
{
Personnell::to_string();
cout " title: " title endl;
}
//Staff class and functions
class Staff : public Personnell
{
public:
Staff();
Staff(string JobPosition, int Income, string Name, string PhoneNumb, string EmAddress);
virtual void to_string() const override; //subclasses Personnell and adds a JobPosition
private:
string jobPosition;
};
Staff::Staff()
{
}
Staff::Staff(string JobPosition, int Income, string Name, string PhoneNumb, string EmAddress) : Personnell(Income, Name, PhoneNumb, EmAddress)
{
jobPosition = JobPosition;
}
void Staff::to_string() const
{
Personnell::to_string();
cout " position: " jobPosition endl;
}
int main()
{
Individual* individual[5];
individual[0]= new Individual("Nancy","123-456-789", "nancy@imail.com");
individual[0]->to_string();
cout endl;
individual[1]= new CollegeStudent("Sophmore year", "Jessica", "111-222-3333", "jessicajess@uni.edu");
individual[1]->to_string();
cout endl;
individual[2]= new Personnell(40000, "Alfred", "444-555-7777", "alfredal@work.com");
individual[2]->to_string();
cout endl;
individual[3]= new Faculty("Teacher",55000, "David", "888-999-1010", "david@teacher.edu");
individual[3]->to_string();
cout endl;
individual[4]= new Staff("Custodian",45000, "Sam", "101-011-1212", "sam@custodian.edu");
individual[4]->to_string();
}
Individual named: PhoneNumb: email Address:
Individual named: PhoneNumb: email Address: year type: Sophmore year
Individual named: PhoneNumb: email Address: income: 40000
Individual named: PhoneNumb: email Address: income: 55000 title: Teacher
Individual named: PhoneNumb: email Address: income: 45000 position: Custodian
::\Users\dcbra\Documents\CSC 252 Assignments Codes\Codingquestions\x64\Debug\Codingquestions.exe (process 31268) exited
ith code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the conso
e when debugging stops.
ress any key to close this window ...
 C++ code. Why does my output not display the name, phone

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!