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());
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/266073.html