Templates in classes => what is wrong?

Xan xancorreu at gmail.com
Sun Apr 15 04:16:42 PDT 2012


hi,

I have this code:

import std.conv, std.stdio, std.stream, std.string;
import std.socket, std.socketstream;
import std.datetime;

class Algorisme(U,V) {
     string nom;
     uint versio;
     V delegate (U) funcio;

}

int main(string [] args)
{
     auto alg = Algorisme!(int,int);
     alg.nom = "Doblar";
     alg.versio = 1;
     alg.funcio = (int a) {return 2*a};
}

but when I compile I receive errors:

$ gdmd-4.6 algorisme.d
algorisme.d:22: found '}' when expecting ';' following return 
statement
algorisme.d:25: found 'EOF' when expecting ';' following statement
algorisme.d:25: found 'EOF' when expecting '}' following compound 
statement


What is wrong?

Thanks in advance,
Xan.


More information about the Digitalmars-d-learn mailing list