I have the following inheritance structure:
template<unsigned int t>
class Base {
protected:
int a;
};
template<unsigned int t>
class Derived1 : public Base {
};
template<unsigned int t>
class Derived2 : public Base {
};
What I'd like is to have a Derived1 constructor take a Derived2 object as a argument and then access the protected member 'a' in the Base class.
I've added the following line to the base class:
template<unsigned int u> friend class Derived2;
So that it looks as follows:
template<unsigned int t>
class Base {
protected:
int a;
template<unsigned int u> friend class Derived2;
};
When I compiled it, I get error C2248: "cannot access protected member declared in class Base"