cout was not declared in this scope c++ error [ SOLVED ]

0
159

There are 3 possible reasons of this error.

  1. You are missing the header file <iostram> in you program
  2. You are not using std:: before cout in your main program ( if you did not declare it before main program ).
  3. You are missing using namespace std before main program.

 

Here is an example in which using namespace std is missing and also did not use std:: before cout statement so we have error ” cout was not declared in this scopes “.

cout was not declared in this scope

How to solve ” cout was not declared in this scope error ?

There are three ways to solve this error.

Solution 1

1st way to solve is to put std:: before cout and use std:: every time when you put cout statement in your program.

solution 1 for cout was not declared error

Solution 2

Declare using std::cout before main function so you will not face ” cout was not declare in this scope error “.

solution 2 for cout was not declared error

Solution 3

You can put using namespace std before main program so that you don’t have to use std:: before every cout statement in your program. See picture below after solving this error with using namespace std.

solution 3 for cout was not declared in this scope error

Suggestions

Use ” using namespace std ” before main program so that you will not have to face this ” cout was not declare in this scope ” error and you will not have to use std:: before using cout statement.

LEAVE A REPLY

Please enter your comment!
Please enter your name here