Suppose there are two classes like so
class Locator
{
public:
// this goes to the specified latitide and longitude
bool GoToLocation(long lat, long longtd);
};
class HouseLocator : private Locator
{
public:
// this internally uses GoToLocation() after fetching the location from address map
bool GoToAddress(char *p);
}
I make private inheritance to block GoToLocation() on HouseLocator because it doesn't make sense there and to force people to use the proper interface.
Now my question is, how can I prevent this kind of casting?
HouseLocator *phl = new HouseLocator;
Locator *pl = (Locator*)phl;
pl->GoToLocation(10, 10);
Should I just document not to do this and leave the rest to the user, I mean, if he makes wrong cast, its his problem?