www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Wrapping C++ class with virtual destructor

reply Gregor =?UTF-8?B?TcO8Y2ts?= <gregormueckl gmx.de> writes:
Hi!

How do I wrap an existing C++ class with a virtual destructor in 
D? Take, for example, this C++ class:

class Base {
public:
     virtual ~Base();

     virtual void foo() = 0;
}

What does the equivalent extern(C++) declaration in D look like? 
I don't care about calling the destructor. My only concern is 
matching the vtable. Changing the C++ code is not an option in my 
case.
Feb 17 2021
parent kinke <noone nowhere.com> writes:
On Wednesday, 17 February 2021 at 22:53:05 UTC, Gregor Mückl 
wrote:
 Hi!

 How do I wrap an existing C++ class with a virtual destructor 
 in D? Take, for example, this C++ class:

 class Base {
 public:
     virtual ~Base();

     virtual void foo() = 0;
 }

 What does the equivalent extern(C++) declaration in D look 
 like? I don't care about calling the destructor. My only 
 concern is matching the vtable. Changing the C++ code is not an 
 option in my case.
extern(C++) class Base { ~this(); abstract void foo(); }
Feb 17 2021