Skip to content
Home » error: ‘cout’ was not declared in this scope

error: ‘cout’ was not declared in this scope

Let’s start the discussion about error: ‘cout’ was not declared in this scope in following Approaches.

Because cout is defined within the std namespace, use std::cout. Alternatively, include a std::cout; directive.

error: ‘cout’ was not declared in this scope

#include<iostream>
using namespace std;

adding above two lines before main will help you

NOTE:
note: suggested alternative:
In file included from class.cpp:1:0:
/usr/include/c++/7/iostream:61:18: note:   ‘std::cout’
   extern ostream cout;  /// Linked to standard output
                  ^~~~

I hope the strategies listed above work for you. Happy coding and come back again.

Similar Post : Double specifier in C