root@supernova-MacBookPro:/home/supernova/Desktop/Impetus/Prog/Nov# g++ GradeBook.cpp -o GradeBookcpp
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status
GradeBook.H
GradeBook.cpp
GradeBook.H
1 2 3 4 5 6 7 8 9 10 11 12
#include <string> // class GradeBook uses C++ standard string class
// GradeBook class definition
class GradeBook
{
public:
explicit GradeBook( 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
private:
std::string courseName; // course name for this GradeBook
}; // end class GradeBook
#include <iostream>
#include "GradeBook.h" // include definition of class GradeBook
usingnamespace std;
// constructor initializes courseName with string supplied as argument
GradeBook::GradeBook( string name )
: courseName( name ) // 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\n" << getCourseName()
<< "!" << endl;
} // end function displayMessage