On Friday, 2 June 2017 at 23:34:14 UTC, Ali Çehreli wrote:
You've probably seen H. S. Teoh's answer but still... :)
...
Ali
Awesome, thanks everyone!
You've probably seen H. S. Teoh's answer but still... :)
On 06/02/2017 04:05 PM, Mark wrote:
> Am I supposed to write template Struct(T) { class Stack { ... } }?
Not necessary because in this case it's the same thing as
class Stack(T) {
// Don't templatize functions in here (in general)
}
On Fri, Jun 02, 2017 at 11:05:43PM +, Mark via Digitalmars-d-learn wrote:
[...]
> Stefan, what do you mean that it must be a template?
>
> Am I supposed to write template Struct(T) { class Stack { ... } }?
No, he means to turn class Stack into a template by adding a template
parameter to it,
Awesome. That worked.
On Friday, 2 June 2017 at 22:30:28 UTC, Stefan Koch wrote:
On Friday, 2 June 2017 at 22:21:07 UTC, Mark wrote:
Hello,
I am trying to make a class that can accept any type as an
argument.
[...]
the stack class needs to be a template as well.
This is not java ;)
On Fri, Jun 02, 2017 at 10:21:07PM +, Mark via Digitalmars-d-learn wrote:
> Hello,
>
> I am trying to make a class that can accept any type as an argument.
>
> Here is the class:
>
>
> import std.container: SList;
>
>
> class Stack {
>
> private SList!T list;
> private int _size;
>
On Friday, 2 June 2017 at 22:21:07 UTC, Mark wrote:
Hello,
I am trying to make a class that can accept any type as an
argument.
[...]
the stack class needs to be a template as well.
This is not java ;)
Hello,
I am trying to make a class that can accept any type as an
argument.
Here is the class:
import std.container: SList;
class Stack {
private SList!T list;
private int _size;
this(T)() {
list = SList!T;
_size = 0;
}
public void push(T)(T item) {