Posts

Showing posts with the label Member Access and Inheritance

Member Access and Inheritance

Member Access and Inheritance: Although a subclass includes all of the members of its superclass, but cannot access those members of the superclass that  declare as private. Here the Example : // This program uses inheritance to extend Box. class Box {   double width;   double height;   double depth;   // construct clone of an object   Box(Box ob) { // pass object to constructor     width = ob.width;     height = ob.height;     depth = ob.depth;   } // constructor used when all dimensions specified   Box(double w, double h, double d) {     width = w;     height = h;     depth = d;   }   // constructor used when no dimensions specified   Box() {     width = -1;  // use -1 to indicate     height = -1; // an uninitialized     depth = -1;  // box   } // constructor used when cube is created...