code is:
#include <iostream>
int main(int argc, char *argv[])
{
cout << “hello world” << endl;
}
when compile the erro info is below:
test@HuiT43 ~/sutdy $ g++ scat. cpp -o scat
scat. cpp: In function `int main(int, char**)’:
scat. cpp:12: error: `cout’ was not declared in this scope
scat. cpp:12: error: `endl’ was not declared in this scope
the reason is :
This is becuase C++ 1998 requires cout and endl be called ‘std::cout’ and ‘std::endl’, or that a proper using directives such as ‘using namespace std;’ be used.
#include <iostream>
int main(int argc, char *argv[])
{
std::cout << “hello world” << std::endl;
}
or
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
cout << “hello world” << endl;
}
Read More:
- error: `cout’ was not declared in this scope
- error: ‘NULL’ was not declared in this scope
- error: ‘vector‘ was not declared in this scope|
- g++ error: ‘printf’ was not declared in this scope
- error: ‘exit’ was not declared in this scope
- error: ‘atoi’ was not declared in this scope
- c++ error: ‘malloc’ was not declared in this scope
- error: ‘memcpy’ was not declared in this scope
- Analysis of the causes of errors in G + + compilation “was not declared in this scope”“
- g++ c++ error: ‘malloc’ was not declared in this scope
- [Error] ‘sort’ was not declared in this scope
- Arduino ide 1.6.9 problems encountered error:’TKD2′ was not declared in this scope
- Arduino reports an error when writing a custom library file to solve the problem of not name of type, not declared in this scope
- error: ‘CV_BGR2GRAY’ was not declared in this scope
- Error:‘itoa’ was not declared in this scope
- Code:: blocks prompt nullptr’s was not declared in this scope
- error: ‘stoi’ was not declared in this scope linux (Fixed)
- Format control of cout cout.width () and cout.fill ()
- Code::Blocks 12.11 error: ‘nullptr’ was not declared in this scope&GNU GCC -std=gnu++0x
- error C2065: ‘cout’ : undeclared identifier