import std.stdio; class Box { protected: double width; } class SmallBox:Box { // SmallBox is the derived class. public: double getSmallWidth() { return width ; } void setSmallWidth( double wid ) { width = wid; } } void main( ) { SmallBox box = new SmallBox(); // set box width using member function box.setSmallWidth(5.0); writeln("Width of box : ", box.getSmallWidth()); }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more