Sunday, September 26, 2010

error: ‘cout’ was not declared in this scope

When using cout and cin for standard output and standard input purposes without "using directive", compiler generates an error message about undeclared cout and cin. In order to get rid of this error message, it is required to add "using namespace std" using directive at a new line.
App.cpp file
#include "App.h"
#include <iostream>
using namespace std;

void App::HelloWorld(){

    cout << "Hello World";
}

In addition to #include <iostream> preprocessor directive, insertion of "using namespace std" helps to compile successfully.

No comments:

Post a Comment