Define "createXXX" functions for the constructors of class XXX
Johan Engelen via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jan 24 12:10:37 PST 2016
On Saturday, 23 January 2016 at 19:42:29 UTC, Johan Engelen wrote:
> Hi all,
> While trying to interface C++ and D, I have to new a few D
> objects in C++ code. I am doing this using a D function: "XXX
> createXXX(...) { return new XXX(...); }".
An easier way for trivial constructors (note parents!), is to
also define the constructor inline in C++ header.
in .d:
extern (C++) class Klass {
int b;
this(int a) { b = a+1; }
}
in .h:
class Klass {
int b;
Klass(int a) { b = a+1; }
};
It's what DDMD does in a few cases.
More information about the Digitalmars-d-learn
mailing list