I had written a simple c++ program bit it shows this error.

June 3, 2012 at 06:17:54
Specs: Windows 7, pentium 4 2GHz/4 gigs
'cout':undeclared identifier. How to solve it?

See More: I had written a simple c++ program bit it shows this error.

Report •


#1
June 3, 2012 at 07:16:05
Some days, I feel like I keep repeating the same jokes. This would make me sad, but then I realize I keep repeating the same jokes because people keep repeating the same mistakes, and that is what makes me sad.

That's simple. Modify the source code you gave us to the following:

How To Ask Questions The Smart Way


Report •

#2
June 24, 2012 at 13:10:31
#include <iostream>
int main(){
	cout << "Hello World\n";
	return 0;
}

A Basic hello World that would output this error..

Basicly what this error code is telling you is that "cout" isn't found anywhere.
To solve this problem simple put:

std::cout << "";

Now an easier way would to just be to use namespace std;
for code without the "cout" undeclared identifier see below.

#include <iostream>
int main(){
	std::cout << "Hello World\n";
	return 0;
}

OR

#include <iostream>
using namespace std; //this allows the std:: to be global to all functions.
int main(){
	cout << "Hello World\n";
	return 0;
}


Report •

#3
February 3, 2013 at 00:29:35
You probably did not declare the following:

using namespace std;


Report •

Related Solutions

#4
February 4, 2013 at 03:59:01
LOL If it waited from June til now I guess it wasn't urgent.

=====================
M2 Golden-Triangle


Report •

Ask Question