You need to specify the std::
namespace:
std::cout << .... << std::endl;;
Alternatively, you can use a using
directive:
using std::cout;
using std::endl;
cout << .... << endl;
I should add that you should avoid these using
directives in headers, since code including these will also have the symbols brought into the global namespace. Restrict using directives to small scopes, for example
#include <iostream>
inline void foo()
{
using std::cout;
using std::endl;
cout << "Hello world" << endl;
}
Here, the using
directive only applies to the scope of foo()
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…