I created a class and when trying to print the result of a class method to the console my compiler says
Illegal operand types: The operands are of the wrong type, casting the operands to a different type.
The line it chokes on looks like this:
Code:
cout << "Your cat is " << mycat.getAge << " years old.";
This is where I am stumped. mycat is an instance of the class cat. The method getAge returns an int, so I can't see any reason for this peice of code not to work.
Here is the getAge method.
Code:
int cat::getAge(){
return age;
}
I'm new to C++, haveing an already solid grasp of C, trying to migrate towards C++.
Can anyone please lend a hand.