I'm studying c++ namespace and i made a simple code to understand it. In particular i made this code and i don't understand why it doesn't give me the compiler error that i'have already decleare the variable 'a'. Is the compiler help me in some way?
#include<iostream>
using namespace std;
namespace funzioni_e_altro
{
int a=5;
int b=20;
int c=10;
}
int main()
{
using namespace funzioni_e_altro;
int a=0;
cout<<funzioni_e_altro::a<<"\n";
cout<<b<<"\n";
cout<<a<<"\n";
return 0;
}
I expect it gave me a compiler error, but it gave me the outputs:
5
20
0