Whoopee, not working on that socket library for the moment. I\'m trying to educate myself a little more in C++.
With classes, is there a way to make a variable read-
A simple solution, like Rob, but without contructor:
class myClass {
private:
int m_x=10; // Note: different name than public, read-only interface
public:
const int& x=m_x;
};
int main() {
myClass temp;
// temp.x is const, so ...
cout << temp.x << endl; // works
// temp.x = 57; // fails
}
Is like a get methode, but shorter. Interesant question ... something like. extent const bool member; can save a lot of getters ...but I don't know languages with this feature...