Hey, just a quick question about inheritance.
Heres some basic code to try explain...
class base
{
public:
object1 anObj;
void setName(void);
};
void base::setName(v oid) { anObj.giveName( "name"); }
class derived : base
{
public:
object2 anObj;
};
Ok so object1 and object2 both have the giveName(string ) method. The global object anObj changes type, but the giveName() method is still valid. So i guess im trying to ask if its possible for object2 anObj to override object1 anObj so that derived::setNam e() will set the name of object2 anObj?
Heres some basic code to try explain...
class base
{
public:
object1 anObj;
void setName(void);
};
void base::setName(v oid) { anObj.giveName( "name"); }
class derived : base
{
public:
object2 anObj;
};
Ok so object1 and object2 both have the giveName(string ) method. The global object anObj changes type, but the giveName() method is still valid. So i guess im trying to ask if its possible for object2 anObj to override object1 anObj so that derived::setNam e() will set the name of object2 anObj?
Comment