public class Rectangle { public: void setWidth(double w) {itsWidth=w;} void setHeight(double h) {itsHeight=w;} double getHeight() const {return itsHeight;} double getWidth() const {return itsWidth;} private: double itsWidth; double itsHeight; }; public class Square extends Rectangle { public setWidth(double w) { super.setWith(w); super.setHight(w); } // pero no resuelve el problema, porque en // otro método:podemos tener void XX(Rectangle r) // y dentro de éste los métodos algo como: /* void XX (Rectangle r) { r.setWidth(5); r.setHight(4); if (r.getHight()+r.getWidth() == 9) System.out.println("Asignación correcta"); } */ } }