I am working on the \'driver\' part of my programing assignment and i keep getting this absurd error:
error C2065: \'cout\' : undeclared identifier
Try it, it will work. I checked it in Windows XP, Visual Studio 2010 Express.
#include "stdafx.h"
#include <iostream>
using namespace std;
void main( )
{
int i = 0;
cout << "Enter a number: ";
cin >> i;
}
It was the compiler - I'm now using Eclipse Galileo and the program works like a wonder
I had same problem on Visual Studio C++ 2010. It's easy to fix. Above the main() function just replace the standard include lines with this below but with the pound symbol in front of the includes.
# include "stdafx.h"
# include <iostream>
using namespace std;
Are you sure it's compiling as C++? Check your file name (it should end in .cpp
). Check your project settings.
There's simply nothing wrong with your program, and cout
is in namespace std
. Your installation of VS 2010 Beta 2 is defective, and I don't think it's just your installation.
I don't think VS 2010 is ready for C++ yet. The standard "Hello, World" program didn't work on Beta 1. I just tried creating a test Win32 console application, and the generated test.cpp
file didn't have a main()
function.
I've got a really, really bad feeling about VS 2010.
If the only file you include is iostream and it still says undefined, then maybe iostream doesn't contain what it's supposed to. Is it possible that you have an empty file coincidentally named "iostream" in your project?
Include the std library by inserting the following line at the top of your code:
using namespace std;