convert "class of" in pascal to D.
Namespace
rswhite4 at googlemail.com
Wed Jan 30 06:53:51 PST 2013
Please post next time in D.learn.
In D it is still like in other C like languages:
class A {
public:
this() { writeln("A CTor"); }
}
A a = new A(); create a new object of type A and print "A CTor"
Because D has no standard copy CTor for classes, you must declare
your own:
class A {
public:
this() { writeln("A CTor"); }
this(ref const A a) { writeln("A copy CTor"); }
}
which is called with:
A a = new A();
A ac = new A(a); // <- calls copy CTor
More information about the Digitalmars-d
mailing list