How to pass a class by (const) reference to C++
Jan at Krassnigg.de
Sun Dec 12 21:24:39 UTC 2021
In D I have an extern(C++) class:
extern(C++) class A
// other stuff
An a function that takes A by const reference:
void CppFunc(const A& arg);
But how do I bind this in D ?
extern(C++) void CppFunc(A arg); // tries to pass as 'A*'
extern(C++) void CppFunc(ref const(A) arg); // tries to pass as
'A const * const &'
I have solved similar problems with other classes by declaring
them as struct in D, but that only works for classes that have no
virtual functions. I now have a class where I do need to use a
class on the D side, and now I have problems passing these
objects to C++.
More information about the Digitalmars-d-learn