I learn C++ and COM through the books.
In the IDE MS Visual Studio 2012 I have created new empty C++ project, and added some existing files to it. My CPP file contains #include<iostream>
row, but in editor I got such messages:
Error: identifier "cout" is undefined
end
Error: identifier "endl" is undefined
Screen:
Why it happens?
This question is related to
c++
visual-studio
com
visual-studio-2012
The problem is the std namespace you are missing. cout
is in the std namespace.
Add using namespace std;
after the #include
You can add this at the beginning after #include <iostream>
:
using namespace std;
cout
is in std namespace, you shall use std::cout
in your code.
And you shall not add using namespace std;
in your header file, it's bad to mix your code with std namespace, especially don't add it in header file.
Source: Stackoverflow.com