simple little program from a book. One of the exercises is to modify it to use displayMessage to output the "Welcome" message and the name of the Professor. Problem is everytime I do it the name of the Course and the professor are the same. What am I doing wrong?
/////////////////////
//main function
#include <iostream>
using namespace std;
#include "3.11.h"
int main()
{
GradeBook gradeBook1("Ben");
GradeBook professorName("Jammin");
return 0;
}
//Seperate Source-Code file
#include "3.11.h"
GradeBook::GradeBook( string name )
{
setCourseName(name),
setProfessorName(name),
displayMessage();
}
void GradeBook::setCourseName( string name )
{
courseName = name;
}
void GradeBook::setProfessorName( string name )
{
professorName = name;
}
string GradeBook::getCourseName()
{
return courseName;
}
string GradeBook::getProfessorName()
{
return professorName;
}
void GradeBook::displayMessage()
{
cout << "Welcome to the Grade Book for: " << getCourseName() << "!" << endl;
cout << "\nThis course is presented by: " << getProfessorName() << "!" << endl;
}
//Header File
#include <iostream>
#include <string>
using namespace std;
class GradeBook
{
public:
GradeBook( string );
void setCourseName( string );
void setProfessorName( string );
string getCourseName();
string getProfessorName();
void displayMessage();
private:
string courseName;
string professorName;
};