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:
double length;
double getLength() {
return length ;
}
void setLength( double len ) {
length = len;
}
}
void main( ) {
Line line = new Line();
// set line length
line.setLength(6.0);
writeln("Length of line : ", line.getLength());
// set line length without member function
line.length = 10.0; // OK: because length is public
writeln("Length of line : ", line.length);
}
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more