error in the code

if i dont call the displayMessage function everything works fine but if i do call it as in the follwing the compiler gives error
" no match for 'operator<<' in 'std::cout << (&gradeBook1)->GradeBook::displayMessage()"

here's the code
#include <iostream>
#include<string>
using namespace std;

class GradeBook
{
public:
GradeBook(string name)
{
setCourseName(name);
}
void setCourseName(string name)
{courseName=name;}

string getCourseName()
{return courseName;}

void displayMessage()
{cout<<"Welcome to the grade book for\n"<<getCourseName()<<"!"<<endl;
}

private:
string instructor;
string courseName;
};

int main {
GradeBook gradeBook1("CS101 introduction to C++ Programming");
GradeBook gradeBook2("CS102 Data Structures in C++");
cout<<gradeBook1.displayMessage();
cout<<"gradeBook1 created for course:"<<gradeBook1.getCourseName()<<"\ngradeBook2 created for course:"<<gradeBook2.getCourseName();


system("pause>nul"); };
"main" should be main()
"cout<<gradeBook1.displayMessage();" should be "gradeBook1.displayMessage();";
bcs you use already cout in the function displayMessage()
It works like that. Anything else ?
Topic archived. No new replies allowed.