#include
class A{};
template class B{};
template class C: public A, public B
{
};
template class D: public C
{
std::vector vector;
public:
void add(T obj){
//push to vector
}
};
int main()
{
D* d=new D();
B* var1=d;
//Now I want to pass var1 to 'd'
d->add(var1);
//at this point compiler fails, stating it cannot convert types, B* to B*.
}
< /code>
Ошибка: < /p>
:23:12: error: cannot convert 'B*' to 'B*'
23 | d->add(var1);
| ^~~~
| |
| B*
:12:20: note: initializing argument 1 of 'void D::add(T) [with T = B*]'
12 | void add(T obj){
|
< /code>
Ссылка на онлайн -компилятор. < /p>
Я понимаю, почему компилятор терпит неудачу. B *