Error: identifier “cout” is undefined

I ran across the following issue when trying to compile my AztecOO source code outside of Trilinous.

example/AztecOO/adapt_main.cpp(94): error: identifier "cout" is undefined
cout << comm << endl;
^
example/AztecOO/adapt_main.cpp(94): error: identifier "endl" is undefined
cout << comm << endl;
^
example/AztecOO/adapt_main.cpp(96): error: identifier "cerr" is undefined
if(argc != 2) cerr << "error: enter name of data file on command line" << endl;

Fix
The compiler doesn’t recognize that these methods come from the standard library. Therefore, I must tell it with the following commands:

using std::cout;
using std::endl;
using std::cerr;

Credit goes to http://stackoverflow.com/questions/13208547/the-includeiostream-exists-but-i-get-an-error-identifier-cout-is-undefine.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.