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