how does it work? are the variables stored in special registers or memory? im looking at the register/memory windows in visual but i cant understand it 🙁
#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 first::x;
using second::y;
cout << x << endl;
cout << y << endl;
cout << first::y << endl;
cout << second::x << endl;
return 0;
}
class CRectangle {
int x, y;
public:
void set_values (int,int);
int area (void);
private:
int param;
} rect;
From the machine’s perspective, there’s nothing different about
privateornamespace. Those are just identifiers for the compiler. That is, the compiler enforces access rules, which is why you get compiler errors for doing something you shouldn’t. The binary code the compiler ultimately produces, however, doesn’t make any distinction about what the data is.