Hello, my entire program (including the header files) all compile. But when I go to test my program, my get is not being shown in the console window, i'm not sure what the issue is. Help is appreciated.
Just some program context: Make a program that uses derived classes "professor" & "student". They come from the parent class "Person". After making the classes test the output by saying all the teachers names & locations. Also display the one students name, and all the courses being taken.
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
|
#include <iostream>
#include <string>
#include "Person.h"
#include "Professor.h"
#include "Student.h"
using namespace std;
int main()
{
// create object of the Person class
Professor professor1;
Student student1;
// call members of the base class
professor1.name();
professor1.Setname("Ms.Puff");
student1.name();
student1.Setname("Spongebob");
// call members from the derived class
professor1.office();
professor1.Settype("The Bikini Bottom");
student1.courses();
student1.Settype("Driving Lessons, Cooking");
// use get of the student and professor object as an argument
professor1.displayInfo(professor1.Getname());
student1.displayInfo(student1.Getname());
}
|
Header files for "person"
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
|
#include <string>
#ifndef PERSON_H
#define PERSON_H
using namespace std;
class Person // parent class
{
public:
Person();
virtual ~Person();
string Getname() { return m_name; }
void Setname(string val) { m_name = val; }
string Gettype() { return m_type; }
void Settype(string val) { m_type = val; }
void office();
void courses();
protected:
string m_type;
private:
string m_name;
};
#endif // PERSON_H
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#include "Person.h"
#include <iostream>
#include <string>
Person::Person()
{
m_type = "";
m_name = "";
}
Person::~Person()
{
//dtor
}
void Person::office()
{
cout << "This teacher is located in office: " << endl;
}
void Person::courses()
{
cout << "The student is taking these courses: " << endl;
}
|
Header File for "professor"
#include <string>
#include "Person.h"
#ifndef PROFESSOR_H
#define PROFESSOR_H
using namespace std;
class Professor : public Person // professor is child class
{
public:
Professor();
virtual ~Professor();
void name();
void office();
void displayInfo(string c);
protected:
private:
};
#endif // PROFESSOR_H
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
|
#include "Professor.h"
#include <string>
#include <iostream>
using namespace std;
Professor::Professor()
{
//ctor
}
Professor::~Professor()
{
}
void Professor::name()
{
}
void Professor::office()
{
}
void Professor::displayInfo(string c)
{
cout << "The professors name is: " << endl;
cout << "Their office is located in: " << endl;
}
|
Header file for "student"
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
|
#include <string>
#include "Person.h"
#ifndef STUDENT_H
#define STUDENT_H
using namespace std;
class Student : public Person // student is child class
{
public:
Student();
virtual ~Student();
void name();
void courses();
void displayInfo(string c);
protected:
private:
};
#endif // STUDENT_H
|
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
|
#include "Student.h"
#include <string>
#include <iostream>
using namespace std;
Student::Student()
{
// ctor
}
Student::~Student()
{
}
void Student::name()
{
}
void Student::courses()
{
}
void Student::displayInfo(string c)
{
cout << "The students name is: " << endl;
cout << "The courses they're attending are: " << endl;
}
|
MY OUTPUT:
The professors name is:
Their office is located in:
The students name is:
The courses they're attending are:
|
: Why is the teachers name, location, and the students name and courses not being displayed?