Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

D Protected Members

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()); 
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.