Tuesday, April 9, 2013

‘cout’ was not declared in this scope


 ‘cout’ was not declared in this scope
if you forget to include iostream or to use the std namespace.
WRONG
 #include <iostream>  // no using namespace std;
 int main(void) 
 {
   cout << "A";
   return 0;
 }

ALSO WRONG
 using namespace std;   // no #include iostream
 int main(void) 
 {
   cout << "A";
   return 0;
 }
RIGHT
 #include <iostream>   // one of two
 using namespace std;    // two of two, yay!
 int main(void) 
 {
   cout << "A";
   return 0;
 }

No comments:

Post a Comment