Question on class templates
anonymous
anonymous at example.com
Fri Jun 7 11:06:25 PDT 2013
On Friday, 7 June 2013 at 17:52:48 UTC, Eric wrote:
>
> interface Identity(V, K)
> {
> }
>
> class X(V, K) : Identity!(V, K)
> {
> private K k;
>
> public this(K k) { this.k = k; }
> }
>
> void main()
> {
> auto x = new X!(X, double)(6.0);
> }
>
> Hi -
>
> I have the code above, but the line in main() gives the
> following compile error:
> Error: template instance X!(X, double) does not match template
> declaration X(V, K)
>
> If I change the template parameter X to something else, like
> string, it compiles fine. But I want the Identity interface to
> know the type of the implementing class. Is that possible?
>
> Thanks,
>
> Eric
class X(K) : Identity!(X, K)
auto x = new X!(double)(6.0);
More information about the Digitalmars-d-learn
mailing list