November 30, 2019 Alias of template class | ||||
---|---|---|---|---|
| ||||
I defined a class: class KNN(size_t k){} I want to define an alias for KNN when k=5, alias KNN5 = KNN!5; So that I could define a variable as KNN5 knnObject; Then create it later as knnObject = new KNN5(); But the compiler gives error for the alias line: Error: template instance KNN!5 KNN is not a template declaration, it is a class What is the way accomplishing this? |
November 30, 2019 Re: Alias of template class | ||||
---|---|---|---|---|
| ||||
Posted in reply to tcak | On Saturday, 30 November 2019 at 09:39:59 UTC, tcak wrote:
> I defined a class:
>
> class KNN(size_t k){}
>
>
> I want to define an alias for KNN when k=5,
>
> alias KNN5 = KNN!5;
>
>
> So that I could define a variable as
>
> KNN5 knnObject;
>
>
> Then create it later as
>
> knnObject = new KNN5();
>
>
> But the compiler gives error for the alias line:
>
> Error: template instance KNN!5 KNN is not a template declaration, it is a class
>
>
> What is the way accomplishing this?
My mistake. It works.
|
Copyright © 1999-2021 by the D Language Foundation