betterC: new operator

Dibyendu Majumdar mobile at majumdar.org.uk
Sun Nov 22 11:54:01 UTC 2020


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();
}



More information about the Digitalmars-d mailing list