syntax error : identifier 'cout'

I have the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include<iostream>

using namespace std;

class Animal
{
public:
	Animal(int);
	Animal();
	~Animal(){}

	int GetWeight() const { return itsWeight;}
	void Display() const ( cout<< itsWeight;}  <--This is where the error is

private:
	int itsWeight;
};


int main()
{
	int number;
	cout<<"enter number"<<endl; <-- This is OK
	cin>>number;

	return 0;
}


When I compile it it gives me an error:
error C2061: syntax error : identifier 'cout'

This is on the following line:
void Display() const ( cout<< itsWeight;}

Why does it complain about this cout and not the:
cout<<"enter number"<<endl;


Thanks
That's strange...it looks like it should work fine...are you sure the code you posted is correct?
Line 13 you need to change the ( to a {
( cout<< itsWeight;} to { cout<< itsWeight;}
The code I posted is a copy and paste of what I have in Visual Studio.

Thanks
Moooce already gave you the right answer.
sorry guys my eyesight is not what it used to be.
I will go hang my head in shame now :(

Thanks
That's OK, its a subtle difference in shape :-}
Topic archived. No new replies allowed.