Meditation, The Art of Exploitation

Thinking? At last I have discovered it--thought; this alone is inseparable from me. I am, I exist--that is certain. But for how long? For as long as I am thinking. For it could be, that were I totally to cease from thinking, I should totally cease to exist....I am, then, in the strict sense only a thing that thinks.

Friday, May 05, 2006

Why my class cannot be used in STL container?

The STL containers expect the class provides copy assignment operator and copy constructor. When a class does not have them, the code won't compile. The following rules dictate how a compiler generates default copy assignment operator for a class:

The compiler mustn't define an implicit copy assignment operator

if the class has:

-a nonstatic data member of const type, or

-a nonstatic data member of reference type, or

-a nonstatic data member of class type (or array thereof) with
an inaccessible copy assignment operator, or

-a base class with an inaccessible copy assignment operator.