1

Possible Duplicate:
Conversion of pointer-to-pointer between derived and base classes?
Converting Derived** to Base** and Derived* to Base*

I have an 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;
}

Why do I get error 2440 in MSVC in GetChildList saying "'return' : cannot convert from 'CList** **' to 'IList **"

Thanks for the help, in advance!

Community
  • 1
  • 1
Quest
  • 129
  • 1
  • 1
  • 8

1 Answers1

0

CList is derived from IList, so you can convert CList* to IList*. However, you can't convert CList** to IList**. You need a reinterpret_cast.

Michael
  • 617
  • 4
  • 3
  • Thanks for the response. Is there a way where I can live without reinterpret_cast as it is strictly not advised in a type safe language? – Quest Aug 09 '12 at 05:45