interface A;
class B;
interface C {}
class D {}
interface E : C; // Fails
class F : C; // Fails
interface G : C {} // Passes
class H : C {} // Passes
Interfaces and classes are only allowed to have ";" as their body if they do not inherit from another interface. Why is this?
Comment #1 by k.hara.pg — 2014-09-22T02:00:37Z
I guess that the limitation has came from C++ class declaration syntax.
// C++ code
class C {};
class D : public C; // NG
But I'm not sure the opaque class declaration with base class/interfaces can work with current ABI. For example:
class C { void foo() {} }
class I { void bar(); }
class D : C, I; // opaque with base class/interfaces
D makeD();
void main()
{
D d = makeD();
d.foo(); // might work
d.bar(); // can work...? vtbl of any base interfaces may not be accessible
// because __traits(classInstanceSize, D) is unknown.
}
Comment #2 by robert.schadek — 2024-12-13T18:24:10Z