betterC: new operator
9il
ilyayaroshenko at gmail.com
Tue Nov 24 05:40:21 UTC 2020
On Sunday, 22 November 2020 at 11:54:01 UTC, Dibyendu Majumdar
wrote:
> I had assumed that new operator is not available in betterC.
>
> But in following code, it seems the only way to initialize the
> object correctly ... is there another way I am missing? How
> should one cleanup objects?
>
> import core.stdc.stdio : printf;
>
> extern (C++) abstract class A {
> void sayHello();
> }
>
> extern (C++) class B : A {
> override void sayHello() {
> printf("hello\n");
> }
> }
>
> extern (C) void main() {
> scope b = new B;
> b.sayHello();
> }
Mir's RC classes doesn't use TypeInfo and DRuntime,
http://mir-algorithm.libmir.org/mir_rc_ptr.html
can be used from C++
https://github.com/libmir/mir-algorithm/blob/master/include/mir/rcptr.h
and C#
https://github.com/libmir/mir.net
More information about the Digitalmars-d
mailing list