what is the proper syntax to inherit a pair of nested classes using templates ?

2021-06-10 Thread someone via Digitalmars-d-learn
I am needing pairs of specific nested classes with already-coded collection management; eg: classComputers having nested classComputer as following (as seen by client code that is): - classComputer ← objComputers.add("ID1", "workstation # 1") - classComputer ← objComputers.add("ID2",

Re: Classes and templates

2016-11-01 Thread Hefferman via Digitalmars-d
On Monday, 31 October 2016 at 22:33:11 UTC, John Colvin wrote: On Monday, 31 October 2016 at 19:24:46 UTC, Hefferman wrote: Hello, I've been trying to implement a class for sorting which accepts arrays which "different" data types. Hard to describe, here's my example (filename sorting.d):

Re: Classes and templates

2016-10-31 Thread John Colvin via Digitalmars-d
On Monday, 31 October 2016 at 19:24:46 UTC, Hefferman wrote: Hello, I've been trying to implement a class for sorting which accepts arrays which "different" data types. Hard to describe, here's my example (filename sorting.d): [...] Glad to see you're getting helpful responses here, but

Re: Classes and templates

2016-10-31 Thread Kapps via Digitalmars-d
On Monday, 31 October 2016 at 20:25:18 UTC, Hefferman wrote: for (uint k = 1; k < n; k++) { if (a[k-1] > a[k]) { T tmp = a[k]; a[k] = a[k+1]; a[k+1] = tmp; sorted = false;

Re: Classes and templates

2016-10-31 Thread Hefferman via Digitalmars-d
On Monday, 31 October 2016 at 20:20:09 UTC, Meta wrote: [...] You can't use an un-instantiated template as a type anyway, unlike Java. There the above is illegal because of `BubbleSort b = ...`. The symbol BubbleSort by itself is not a type; you have to instantiate it with template arguments

Re: Classes and templates

2016-10-31 Thread Meta via Digitalmars-d
On Monday, 31 October 2016 at 20:06:22 UTC, Hefferman wrote: On Monday, 31 October 2016 at 19:43:57 UTC, Adam D. Ruppe wrote: On Monday, 31 October 2016 at 19:24:46 UTC, Hefferman wrote: Give a template type when crating it new BubbleSort!(string) for example Is it possible to create this

Re: Classes and templates

2016-10-31 Thread Hefferman via Digitalmars-d
On Monday, 31 October 2016 at 19:43:57 UTC, Adam D. Ruppe wrote: On Monday, 31 October 2016 at 19:24:46 UTC, Hefferman wrote: Give a template type when crating it new BubbleSort!(string) for example Is it possible to create this using "typeof"? E. g. "BubbleSort b = new

Re: Classes and templates

2016-10-31 Thread Adam D. Ruppe via Digitalmars-d
On Monday, 31 October 2016 at 19:24:46 UTC, Hefferman wrote: Whenever I try to compile this, it throws an error "class sorting.BubbleSort(T) is used as a type". How do I get a workaround? Give a template type when crating it new BubbleSort!(string) for example

Classes and templates

2016-10-31 Thread Hefferman via Digitalmars-d
Hello, I've been trying to implement a class for sorting which accepts arrays which "different" data types. Hard to describe, here's my example (filename sorting.d): [code] import std.random; void main() { immutable uint N = 10_000; double[] arr = new double[](N); for (uint k =