I have
class Rect{
// stuff
};
and
class SpecialRect:public Rect{
private:
operator const Rect(){return *this;} // No implicits casts to Rect
public:
// stuff
};
SpecialRect inherits all the properties and methods from Rect except that I want to avoid non-explicit conversions of SpecialRect to the base class Rect.
In the code
SpecialRect oneSpecial;
Rect aRect=oneSpecial; // I want this to not compile. (to remind-me to declare aRect as SpecialTect)
Compiles with no errors. (I know that declaring the base class Rect as private would do it but I don't want to reimplement all its methods.)
Is there a way to achieve this?