C++ keeping access to protected member (of the function argument) when specializing base template class -
could please resolve (the problem persistent under both gcc , vc++).
template <class t> class a{ protected: t a; public: a(int aa=0){a=aa;} virtual ~a(){} virtual void plus(a const *aa){a=a+aa.a;} }; class b:public a<int>{ public: b(int bb=0):a<int>(bb){} virtual ~b(){} void plus(a<int> const *aa){a=a+aa->a;} //<--problem: can access not aa->a? };
this expected.
an instance of b has no right poking around in internals of arbitrary a; has right access part of (other) bs. that's protected keyword means.
Comments
Post a Comment