Why does compiler complain when I try to convert to a base-class?
- by John
class BaseClass
{
...
};
class SubClass
{
...
};
class MyApp
{
SubClass *pObject;
BaseClass *getObject()
{
return pOject;
}
};
I get a compiler error: error C2440: 'return' : cannot convert from 'SubClass *' to 'BaseClass *'
Why doesn't it work, surely you can automatically convert to a base-class without any casting?