I'm new to C++ and I have written an example in CodeBlocks to see how this program works. Here is the program:
#include <iostream>
#include <string>
using std::cout;
using std::cin;
using std::endl;
using std::string;
class GradeBook
{
public:
GradeBook( string name )
{
setCourseName( name );
}
void setCourseName( string name )
{
courseName = name;
}
string getCourseName()
{
return courseName;
}
void displayMessage()
{
cout << "Welcome to the gradebook for \n" << getCourseName() << "!" << endl;
}
private:
string courseName;
};
int main()
{
GradeBook gradeBook1("Introduction to C++");
cout << gradeBook1.displayMessage() << endl;
return 0;
}
And as you can see I have called a displayMessage function at main and it basically should print out a statement based on the argument that I have called ealier in gradeBook1 object.
But the problem is, it does not start and I don't know why!
And here is the error log:
||=== Build: Debug in Youtube (compiler: GNU GCC Compiler) ===|
C:\Users\Pouya\Desktop\C++_Tutorials\Youtube\main.cpp||In function 'int main()':|
C:\Users\Pouya\Desktop\C++_Tutorials\Youtube\main.cpp|35|error: no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'void')|