R
Rune Allnor
Hi folks.
I have some classes which are derived from some base:
class base {
void foo();
void bar();
};
class a : public base {
};
class b: public base{
};
The problem is as follows:
1) I would like to prevent users from making instances of
class base
2) There are no overloaded functions beween the base class
and the derived classes, so I can not use the usual
virtual void overloaded_function() = 0;
in the base class.
As far as I can see, there are two ways to proceed:
1) make some virtual dummy function that the
derived classes need to implement
2) Hide the constructor of base as protected.
From a semantic point of view the latter solution
seems the more elegant. Is this a good solution
or are there traps or snags associated with it?
Rune
I have some classes which are derived from some base:
class base {
void foo();
void bar();
};
class a : public base {
};
class b: public base{
};
The problem is as follows:
1) I would like to prevent users from making instances of
class base
2) There are no overloaded functions beween the base class
and the derived classes, so I can not use the usual
virtual void overloaded_function() = 0;
in the base class.
As far as I can see, there are two ways to proceed:
1) make some virtual dummy function that the
derived classes need to implement
2) Hide the constructor of base as protected.
From a semantic point of view the latter solution
seems the more elegant. Is this a good solution
or are there traps or snags associated with it?
Rune