How to say to compiler that I want to inherit final template bethod of base interface into derived class
    Uranuz via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Sun Jul 20 05:30:18 PDT 2014
    
    
  
The question is in the header:
How to say to compiler that I want to inherit final template 
bethod of base interface into derived class?
I have the following example. I know that it is maybe 
overcomplicated but still I need this feature in my code.
import std.stdio;
interface IBase
{
	
	template getStr(string fieldName)
	{
		final string getStr()
		{
			return "George";
		}
	}
	
	
	string getStr(string fieldName);
}
class Derived: IBase
{
	override string getStr(string fieldName)
	{
		return "Sam";
	}
	
}
void main()
{
	auto obj = new Derived;
	
	writeln( obj.getStr!("aaa")() );
	
}
Compilation output:
/d907/f266.d(33): Error: obj.getStr isn't a template
When I have all of these methods having the same name compiler 
shadows template method from the base interface. So the question 
is how to inherit template method without reimplementing it in 
derived class?
    
    
More information about the Digitalmars-d-learn
mailing list