Wednesday, June 6, 2007

C++ item 6

All compiler generated functions are public

To make sure that none can call a function foo() in your class.

Declare it as a private foo functions.

And don't define it.

Then even if friend or member functions were to invoke it then you will get a linker error.

A better way to get this linker error at compile time is :
Create a uncopyable class with cons , des, copy constructror et.c.

Now have general_class privately inherit from pupcopyabele class

Things to remember:

To disallow functionality automatically provided by compilers. Declare the corresponding member functions private and give no implementation. Using a base class like uncopyable is one wat to do this

Umesh Kumar

No comments: