可能重复:
Conversion of pointer-to-pointer between derived and base classes?
Converting Derived** to Base** and Derived* to Base*
我有一个intf + class
class IList
{
public:
virtual IList** GetChildList()=0;
virtual void SetChildList(IList**)=0;
~IList();
};
class CList:public IList
{
CList** m_lst;
public:
IList** GetChildList()=0;
virtual void SetChildList(IList**);
//...
};
IList** CList::GetChildList()
{
return m_lst;
}
为什么我在GetChildList中的MSVC中收到错误2440,说''return':无法从'CList ** **'转换为'IList **'
提前感谢您的帮助!
答案 0 :(得分:0)
CList派生自IList,因此您可以将CList *转换为IList *。但是,您无法将CList **转换为IList **。你需要一个reinterpret_cast。