How to call a extern C++ class constructor ?

kinke noone at nowhere.com
Sat Feb 1 14:52:21 UTC 2020


On Saturday, 1 February 2020 at 08:15:20 UTC, Luhrel wrote:
> But somehow I got a segfault on dcpp.getNumber(true).

That's because you declare it as virtual in D (default for 
classes, use `final`), but non-virtual in C++. You also forgot to 
add the class field to the D declaration (yes, D needs to know 
about the struct layout and size too, especially when you `new` 
the class in D and let the GC allocate it).

Trivial cases like yours should actually work wrt. using C++ ctor 
implementations from D IIRC.


More information about the Digitalmars-d-learn mailing list