c++ - Template class hierarchy friend inheritance -
i'm tinkering c++ , facing following problem:
given:
class { int avar; public: a(){} virtual ~a(){}; }; template<class base> class b: public base { int bvar; public: b() : base() {} virtual ~b() {} }; template<class base> class c: public base{ int cvar; public: c() : base() {} virtual ~c() {} } d,e,f,g...
i can sort of branched class hierarchy inherits parameters , functions , such. typedef c<b<a>> abc;
however, supposed have class "manages" combinations of these objects through protected access.
template<class type> struct manager { type current; manager() { current.avar++; current.bvar++; current.cvar++; } ~manager(){} };
and question is: how set a
, b
, , c
classes friend manager regardless of manager
's template type? (e.g. manager
template abc
, eabc
, dabc
, xyzefgabc
, ...)
just have them friend manager:
class { template <typename t> friend struct manager; }; template<class base> class b: public base { template <typename t> friend struct manager; }; // etc.
Comments
Post a Comment