Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 ...
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

Describe how language reflects, builds on, and determines context?

Answered: 1 week ago