Suppose I have a MessageBox class along the following lines:
class MyMessageBox
{
public:
enum Priority {
Prior_Dialog,
Prior_Warning,
// ...
};
enum Icon {
Icon_Question,
Icon_Exclamation,
// ...
};
enum Button {
Button_Yes,
Button_No,
Button_Cancel,
// ...
};
static void Show(Priority pPriority, Icon pIcon, Button pButton1, Button pButton2);
// ...
};
Now, if I want to throw up a messagebox, I have to type out MyMessageBox:: for every single identifier:
MyMessageBox::Show(MyMessageBox::Prior_Dialog, MyMessageBox::Icon_Question, MyMessageBox::Button_Yes, MyMessageBox::Button_No);
Ideally, I’d like some non-macro solution that will allow source files that #include "MyMessageBox.h" to omit the MyMessageBox:: qualifications everywhere. Is this possible?
Maybe it would be convenient if the enumerations and the class are declared in the separate namespace (i.e. enumerations should be declared outside the class) just not to pollute the global namespace.
Client code (some cpp file):