overriding private interface methods
Oleg
code.viator at gmail.com
Tue Oct 23 11:37:48 PDT 2012
Hello. How to override private methods?
import std.stdio, std.conv;
interface abcInterface
{
private double private_func();
public final double func() { return private_func(); }
}
class abcImpl: abcInterface
{
override private double private_func() { return 3.14; } //#1
}
void main()
{
auto abc = new abcImpl;
writeln( abc.func() );
}
This code generate error
#1 Error: function inter.abcImpl.private_func cannot override a
non-virtual function
This private method (private_func) is 'private' because it must
call only in final interface methods (func)
More information about the Digitalmars-d-learn
mailing list