Click here to Skip to main content
15,907,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
please help me understand why this error ?, am doing exercise .i got this code from my book but it tells me that i have this error

C2065: 'cout' : undeclared identifier

look at my code

#include <iostream>

int main ()
{
	cout << "Hello World!\n";
	return 0;
}


am using Visual Studio 2005
Posted
Updated 8-Jul-10 6:44am
v4

you need to either explicitly scope cout from namespace std, or scope the namespace entirely. std::cout will work. I believe it's using namespace std; but I'm so long out of C++, that could be wrong.
 
Share this answer
 
Comments
nandisha 8-Jul-10 12:23pm    
CAN U PLZ HELP ME M HAVING THE SAME ERROR NO WITH CONSTRUNCYING CLASS USING MFC LIBRARIES
cout is defined by <iostream> inside the std namespace.

You can either do
...
std::cout << "your text" << std::endl;
...

or

...
using namespace std;
...
cout << "your text" << std::endl;
...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900