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.
import std.stdio;
class Line {
public:
void setLength( double len ) {
length = len;
}
double getLength() {
return length;
}
this( double len) {
writeln("Object is being created, length = " , len );
length = len;
}
private:
double length;
}
// Main function for the program
void main( ) {
Line line = new Line(10.0);
// get initially set length.
writeln("Length of line : ",line.getLength());
// set line length again
line.setLength(6.0);
writeln("Length of line : ", line.getLength());
}
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more