How to call the following functions in main. (C++) //GradeBook.h // gradebook. h
ID: 3744338 • Letter: H
Question
How to call the following functions in main. (C++)
//GradeBook.h
// gradebook. h file
// GradeBook class definition. This file presents GradeBook's public
// interface without revealing the implementations of GradeBook's member
// functions, which are defined in GradeBook.cpp.
#include <string> // class GradeBook uses C++ standard string class
// GradeBook class definition
class GradeBook
{
public:
GradeBook();
explicit GradeBook( std::string,std::string); // constructor initialize courseName
void setCourseName( std::string ); // sets the course name
std::string getCourseName() const; // gets the course name
void displayMessage() const; // displays a welcome message
void setInstructorName(std::string); // set instructor name
std::string getInstructorName() const; //get instructor name
private:
std::string courseName; // course name for this GradeBook
std::string instructorName;
}; // end class GradeBook
//GradeBook.cpp
// GradeBook member-function definitions. This file contains
// implementations of the member functions prototyped in GradeBook.h.
#include <iostream>
#include "GradeBook.h" // include definition of class GradeBook
using namespace std;
// constructor initializes courseName with string supplied as argument
GradeBook::GradeBook(){ }
GradeBook::GradeBook( string name,string name1 )
: courseName( name ),instructorName(name1) // member initializer to initialize courseName
{
// empty body
} // end GradeBook constructor
// function to set the course name
void GradeBook::setCourseName( string name )
{
courseName = name; // store the course name in the object
} // end function setCourseName
// function to get the course name
string GradeBook::getCourseName() const
{
return courseName; // return object's courseName
} // end function getCourseName
// display a welcome message to the GradeBook user
void GradeBook::displayMessage() const
{
// call getCourseName to get the courseName
cout << "Welcome to the grade book for " << getCourseName()<< "!" << endl;
cout << "This course is presented by " << getInstructorName()<< endl;
} // end function displayMessage
void GradeBook::setInstructorName(string name) // set instructor name
{
instructorName=name;
}
string GradeBook::getInstructorName() const
{
return instructorName;
}
Explanation / Answer
#include #include #include "Grade.h" using namespace std; int main() { GradeBook book = GradeBook("course 1", "instructor 1"); coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.