Variants for interfaces

Mandeep Singh Brar maninder at brars.co.in
Fri Jan 7 06:42:38 PST 2011


Hi,

Is it possible to point a variable to an interface. The below code does not compile.

module testD;
import std.stream;
import std.stdio;
import std.variant;

interface A {
	void func1();
}
class AC: A {
	void func1() {
		writeln("func1");
	}
}
int main() {
	A a = new AC();
	a.func1();
	Variant b = Variant(a);
	return 0;
}

It says that opEquals is not defined for the interface.

Thanks & Regards
Mandeep


More information about the Digitalmars-d-learn mailing list