Re: Points and Slicing???

[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]

Posted by Daniel Longest on April 16, 2001 at 02:02:51:

In Reply to: Points and Slicing??? posted by Earl Wong on April 16, 2001 at 00:30:00:

If you look in the MSDN help file for error C2443, you'll see an example of this error. Basically, if you derive from the base class using private or protected inheritance, you cannot typecast like this in a nonfriend function. I was able to avoid this error by doing it in a function declared as friend (of either the base or derived class). If you check the controlling inheritance slides, you'll see why. Public inheritance means anything can convert from a D* to a B*. Protected inheritance means only members, friends and derived classes from D can convert from D* to B* and private inheritance means that only members and friends can do the conversion.


: I get the following error when I try to assign a derived class pointer to its base class.
: "error C2243: 'type cast' : conversion from 'class plant *' to 'class creature *' exists, but is inaccessible"
: Any help or ideas to tackle the problem would be greatly appreciated thanks
: Earl

Follow Ups:

Post a Followup




Optional Link URL:
Link Title:
Optional Image URL:

[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]