I am currently using something similar in my code:
class B : public A<C> { };
Wouldn't it be better to use typedef?
typedef A<C> B;
It depends. If you want to A<C>, and Bhave been excellent, but related types Bshould expand A<C>. If you want them to be identical, you should use typedef. Can you provide more context?
A<C>
B
typedef
It depends on what you want. If you use different classes to configure template metaprograms, it’s better to create one B.
, , typedef, .
, , typedef.
. , typedef :
typedef A<C> B; func(B param) {...} ... A<C> var; func(var);
, , , A<C>. , typedef - . , , .
, . typedef . , .
, , , A, .
, , .
C ++ typedefs are not "strong", which basically means that Bthey A<C>will be of the same type. If you want to distinguish between two, use a class.
Various options for a strong typedef can be found on the Internet, boost one , for example.
For completeness, I want to add one more point: C
you can easily forward ad B:
class B; void func(B param);