I have a class A
, and two classes, B
and C
, inheriting from A
.
Apart from the methods from A
, each class is to offer different things, and, therefore, I'd like to put them in two different files -- b.hpp
and c.hpp
, since they're templates with inline functions.
I also have a class User
, using both B
and C
classes. In user.cpp
, I should have something close to:
# include "b.hpp"
# include "c.hpp"
class User{
...;
};
Which would raise a compiler redefinition error, for what I'm keeping both classes B
and C
in a bc.hpp
.
The concern here is rather aesthetic other than a programming error: I just don't find very elegant using ifdef / ifndef
directives in small applications -- they always look to me like IDE's solution for people managing too many modules, and for those not even aware of the directives.
Is there any (even nonstandard, but at least sane) workaround for this, or do I have to stick with either having two different classes in the same file and using ifdef / ifndef
?