当前代码:
class A {
// Abstract class
...
};
class B : public A {
// Concrete class
...
};
class C : public B {
// Concrete class
...
};
class D : public C {
// Abstract class
...
};
class E : public A {
// Concrete class
private:
std::deque< std::shared_ptr<A> > m_deque;
public:
E& operator+=( std::shared_ptr<D> temp ) {
m_deque.push_front( temp );
...
}
...
};
尝试重载+=
运算符时,我想将参数temp
推送到双端队列m_deque
。问题是这些类型不匹配。如何将temp
推入deque m_deque
?
我正在尝试输入强制转换temp
,但我不确定如何输入强制转换为祖父母类。