Well for example I have a map class which has some members: sizeX, sizeY, vector of tiles, name etc.
There are 2 basic approaches of managing its variables which are accessed from outside:
- encapsulation, but it adds a lot of code and more typing (setX() and getX() const functions)
- have the variables which are often accessed from outside as public members and keep it easy
I like neither of these. I came up with an idea: a class member, which from outside acts as const (so you can access it easily object.member but it's safe) and inside the class it is non-const. However, as far as I know c++ lacks it. The only (ugly) workaround I know is to have everything const and use const cast inside class functions.
Is there better approach for this in C++ 11? Is there a keyword for it?