In the below code writing the statement A::x=5
is giving the error:
'x' in namespace 'A' does not name a type
Can't we assign a value globally for x
variable?
#include <iostream>
int x = 10;
namespace A
{
int x = 20;
}
A::x=5;
int main()
{
int x = 30;
std::cout << "x = " << x << std::endl;
std::cout << "A::x = " << A::x << std::endl;
std::cout << "::x = " << ::x << std::endl;
}