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());
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/266054.html