class A {
protected:
int fooA;
A() : fooA(0) {}
};
class B {};
template<typename T>
class C : public A {
public:
using A::A;
void fooF(const T element) {
element.fooA = 1;
}
};
class D : public C<B>, public B {
using C::C;
};
int main() {
D d1;
D d2;
d1.fooF(d2);
return 0;
}
error: ‘const class B’ has no member named ‘fooA’ element.fooA = 1;
It seems like when T is particulariced into B, it transforms d2 into its parent class (B), what can I do to avoid that? (I need to do it that way so i can't change the number of classes either its inheritances). Thanks.
Aucun commentaire:
Enregistrer un commentaire