September 10, 2002

Enforcing a Class Object to be Passed by a Pointer or Reference Only

In other words, you don’t want anyone to be able to pass the object of your class “by Value” to a function.To achieve this, override the copy constructor of your class and make it private: class Restrict{public: Restrict(){} ;private: Restrict( const Restrict &s ){} ;}; Using this technique, if someone

Set the Text of the Edit Control Portion of a ComboBox

The following is a way to programatically set the text in the combo box without adding to the list box portion.When using a combo box, if the style is CBS_DROPDOWN, users can enter any text in the edit box portion of it. There is no direct way of adding text

Solving Global Namespace Clashes

The C++ language provides a single global namespace. This can cause problems with global name clashes. For instance, consider these two C++ header files: // file1.hfloat f ( float, int ) ;class sample { … } ;// file2.hclass sample { … } ; With these definitions, it is impossible to