Is there a way to access a private member variable... so that to the user of the class it seems just to be a public const... but in actually fact its just a private member...

For example...

class X { // this class definition doesnt compile... just
private: // the best way to see what i am talkin about
int y;

public:
int y() { return this->y; }
};

X z;

cout << z.y; // this would display the contents of X::y.
z.y = 4; // this would be an error.