Class, constructor and inherance.
holo via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Oct 14 21:43:54 PDT 2015
Please again, any example? I'm trying to figure out how it should
be done but i don't have any base from which i can build some
solution.
#!/usr/bin/rdmd
import std.stdio;
interface RequestResult
{
int add (int x);
}
class B : RequestResult
{
int add(int x)
{
return ++x;
}
}
class A
{
RequestResult go(int varA, int varB)
{
return add(varA + varB);
}
}
void main()
{
B b = new B();
A a = new A();
int x = 12;
int y = 15;
RequestResult c = A.go(x, y);
}
It even don't want to compile, but that probably not what you
ware thinking about.
[holo at ultraxps workplace]$ dmd test.d
test.d(24): Error: undefined identifier 'add'
test.d(38): Error: need 'this' for 'go' of type
'RequestResult(int varA, int varB)'
[holo at ultraxps workplace]$
More information about the Digitalmars-d-learn
mailing list