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 Class Destructor

import std.stdio;

class Line { 
   public: 
      this() { 
         writeln("Object is being created"); 
      }

      ~this() { 
         writeln("Object is being deleted"); 
      } 

      void setLength( double len ) { 
         length = len; 
      } 

      double getLength() { 
         return length; 
      }
  
   private: 
      double length; 
}
  
// Main function for the program 
void main( ) { 
   Line line = new Line(); 
   
   // set line length 
   line.setLength(6.0); 
   writeln("Length of line : ", line.getLength()); 
}

Advertisements
Loading...

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