Let's say I have a multi-ton. The objects themselves are immutable, 
and there are several references that are static const in the class. It 
looks something like this:

class Multiton {
   const int value;
public:
   static const Multiton X;
   static const Multiton Y;
   // Private assignment operator but public constructors.
};

In the .cpp file, I define the actual instances. Life is good. Now I 
want to use them:

class OtherClass {
   Multiton *value;
public:
   OtherClass(const Multiton *argValue);
};

What I want to do is guarantee the following:

* Nobody can modify those constants in any way, shape or form.
* Constructors and other methods in OtherClass are compatible with const 
references.
* It is possible to create multitons, but not modify them.

However, due to const-ness, I keep having to use const_cast to assign 
that pointer. Since the Multiton is is immutable, and has a private 
assignment operator, is there any harm in making those instances 
"static" instead of "static const"?

-- 
John Gaughan
http://www.johngaughan.net/

Reply via email to