Hi, does anyone know why this gives a compiler error ? I tried VS 2005 and Codewarrior:
class Parent {
protected:
int m_Var;
public:
Parent() : m_Var(0) {}
virtual ~Parent() {}
void PubFunc();
};
class Child : public Parent {
protected:
bool m_Bool;
public:
Child() : m_Bool(false) {}
virtual ~Child() {}
void ChildFunc();
};
void RemoveObj(Parent *& ppObj)
{
delete ppObj;
ppObj = 0;
}
int main()
{
Parent* pPObj = 0;
Child* pCObj = 0;
pPObj = new Parent();
pCObj = new Child();
RemoveObj(pPObj);
RemoveObj(pCObj);
return 1;
}
Visual studio says:
refptr.cpp(33) : error C2664: 'RemoveObj' : cannot convert parameter 1 from 'Child *' to 'Parent *&'
Thanks