Templates lots of newbie qs.

Chris Warwick sp at m.me.not
Thu Mar 8 09:09:55 PST 2007


"Daniel Keep" <daniel.keep.lists at gmail.com> wrote in message 
news:espao6$q5k$1 at digitalmars.com...
>> }
>>
>> And are class templates value types or referances types?
>
> They are reference types, just like un-templated classes.

So they need to be explicitly instantiated... this would be an error..

vector!(int) foo;
foo.append();

because foo doesnt reference an actual object yet?

Is it the same syntax as creating a normal class...

vector!(int) foo = new vector!(int);

or with constructor parameters..

vector!(int) foo = new vector!(int)(10); // create a vector with 10 
elements.

that right?

> Probably not since your opIndex and opIndexAssign are virtual methods;
> they can be overridden in subclasses, which makes them difficult to 
> inline.

Does that mean class templates have inheritance??

That sounds complicated lol.


>>
>> ArrayPros(int);
>
> This line above is wrong.  It should be:
>
> mixin ArrayProps!(int);

*checks online docs*

So this creates all stuff inside the ArrayProps template, for type int? And 
puts them into the local scope, even inside a class or struct definition...

I can see that being very useful. :-)

thanks

cw




More information about the Digitalmars-d-learn mailing list