Hi friends,

I'm learning to program in C++.
I'm using Notepad++ to author my code and Cygwin g++ to compile it.

main.cpp : in function 'int main() :
main.cpp : 38 : error: no match for 'operator << '

then a lot of jibberish and number of errors : 1


here take a look at the code

// Classes Practical
// Author : -

#include <iostream>
#include <string>

using namespace std;

class GradeBook{

    GradeBook( string parameter ){
        setObject( parameter );
    //Member Functions
    string getObject(){
        return courseName;
    void setObject( string parameter ){
        courseName = parameter;
    void displayObject(){
        cout << "Data member now contains : " << courseName << endl;

    //Data Members
    string courseName;

int main(){
    GradeBook myObject( "You got Owned, g++ won't compile" );
    cout << "myObject initialized\n" << myObject.displayObject() <<  endl;
    return 0;

Thank you for your time and help.

cout always looks out for a type which it can output or another object of its own data type that is "ostream&" but you are passing a void type to it by using the myObject.displayObject() in line with cout.Rectify it and you are done.

You cannot use a void returning function with cout.

Since you are outputting something on screen using displayObject(), why not just call it separately. Something like ...

GradeBook myObject( "You got Owned, g++ won't compile" );
cout << "myObject initialized\n";

Edited 6 Years Ago by vidit_X: n/a

This question has already been answered. Start a new discussion instead.