I created a c++ Win32 console application in VS2010, and in a separated class I have.
void Thing::display(){
Point pt(0, 0);
for( ; pt.y < m; pt.y++){
for( ; pt.x < m; pt.x++){
if (pt == pi){
std::cout << "[ ]";
}else {
std::cout << "[" << Array[pt.x][pt.y] << "]";
if ( pt.x == m ){
std::cout << std::endl;
}
}
}
}
}
which exists in the Thing class which is split between an h, and a cpp. point is an (x, y) point, and Array is a 2D array of ints, and pi is a private member for current location tracking.it keeps throwing errors of
error C2039: 'cout' : is not a member of 'std'
error C2065: 'cout' " undeclared identifier
and it does the same thing for endl. I can go into my _tmain() and write
cout << "Hello world" << endl
with no problem. when I attempt to tell the compiler for this file
using namespace std;
it throws inteslliSense: name must be a namespace name
Edit: suggestion of putting #include into the header file caused
error C1010: unexpected end of file while looking for precompiled header. did you gorget to add '#include "StdAfx.h"' to your source?
moving the #inlcude to stdafx.h causes same.
Edit2 (resolved):
placed
#include <iostream>
into stdafx.h, and then listed header files for the program. and listed
#include "stdafx.h"
at the beginning of the .cpp files.
Have you included iostream
in your header file?