Wednesday, December 2, 2009

The law of the big 3

If a class owns a pointer to some object (e.g. heap memory or a file handle), the following should be created
- copy ctr
- destructor
- assignment operator

 If a class is to be used in a template, the following are required
- copy ctr
- destructor
- assignment operator

Other things for templates which might be required:
- default ctrs
- equality operator
- less than operator

No comments: