In the code there are some special classes and there are some normal classes. I want to differentiate them because special classes needed to be given different treatment. All these special classes are base (not child of any other class)
To achieve that I am tokenizing special class
es in the source code by inserting an inheritance to them with an empty struct
:
struct _special {}; // empty class
class A : public _special { // A becomes special
...
};
class B { // 'B' remains normal
...
};
class D : public A { // 'D' becomes special due to 'A'
...
};
Whenever needed, I can find segregate special and normal classes using is_base_of<Base,Derived>
. The alternate way would have been of using typedef
inside the special classes:
class A {
public: typedef something _special;
};
The problem is that if A
's child are inheriting from multiple classes then there will be ambiguous typedef
s.
Question: With adding such interface like inheritance with empty class _special
, will it it hurt the current code in any way (e.g. object structuring, compilation error etc.) ?