#include <iostream>
using namespace std;
int b=10;
//b=100;
int main(int argc, char *argv[])
{
cout<<b<<endl;
return 0;
}
There is an error if remove the comment at b = 100.Why is that so.The output is 10 otherwise.
error:C++ requires a type specifier for all declarations.
The global scope can only contain declarations and definitions, not arbitrary statements.
C++ thinks you’re trying to declare and define another variable called
b.