N
Nikos Hatzigiannakis
I cannot understand why the following code does not work. The compiler
displays the error
'x' undeclared (first use this function) in the sentance after the usung
namespace second; statement.
any help will be appreciated .
#include <iostream>
using namespace std;
namespace first
{
int x = 5;
int y = 10;
}
namespace second
{
double x = 3.1416;
double y = 2.7183;
}
int main ()
{
using namespace first;
cout << x << endl;
cout << y << endl;
using namespace second;
cout << x << endl;
cout << y << endl;
system("pause");
}
displays the error
'x' undeclared (first use this function) in the sentance after the usung
namespace second; statement.
any help will be appreciated .
#include <iostream>
using namespace std;
namespace first
{
int x = 5;
int y = 10;
}
namespace second
{
double x = 3.1416;
double y = 2.7183;
}
int main ()
{
using namespace first;
cout << x << endl;
cout << y << endl;
using namespace second;
cout << x << endl;
cout << y << endl;
system("pause");
}