[Issue 12627] extern(C++) interfaces should format

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Apr 24 09:59:38 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12627

yebblies <yebblies at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies at gmail.com

--- Comment #1 from yebblies <yebblies at gmail.com> ---

The requested example of how to create classes usable through extern(C++)
interfaces - pretty much how you'd expect.

import std.stdio;

extern(C++)
interface I
{
    void fun();
}

extern(C++)
class C : I
{
    void fun() { writeln("This works..."); }
}

class D : I
{
extern(C++):
    void fun() { writeln("And so does this!"); }
}

void main()
{
    I i = new C();
    i.fun();
    i = new D();
    i.fun();
}

--


More information about the Digitalmars-d-bugs mailing list