I often find myself wishing I could have an object's member variable be const, but that the system allowed initialization of that const variable after construction. Is there a mechanism that would allow me to do this?
To clarify, here is an example:
class A
{
public:
A(){}
initialize(int x) { c = x; }
private:
const int c;
}
I want to be able to do something like that. I don't have this information at construction, so I can't simply move initialization to the initialization list of the constructor.