Shouldn't the pointers be different

2015-01-07 Thread Nick via Digitalmars-d-learn
When i try to run the following code import std.stdio; void main(){ auto a= new test!int(); a.add(0); a.add(1); } class test(T){ void add(T e){ auto temp= new node(); writeln(new node, temp); } class node{

Re: Shouldn't the pointers be different

2015-01-07 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 7 January 2015 at 10:37:18 UTC, Nick wrote: When i try to run the following code import std.stdio; void main(){ auto a= new test!int(); a.add(0); a.add(1); } class test(T){ void add(T e){ auto temp= new node();

Re: Shouldn't the pointers be different

2015-01-07 Thread bearophile via Digitalmars-d-learn
Nick: The two nodes have the same address, is this right? What you are printing is the address of the reference in the stack frame of add(). If you want to print the reference you can use this: import std.stdio; class Test(T) { static class Node { T v; } void add(T

Re: Shouldn't the pointers be different

2015-01-07 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 7 January 2015 at 10:56:09 UTC, John Colvin wrote: On Wednesday, 7 January 2015 at 10:37:18 UTC, Nick wrote: When i try to run the following code import std.stdio; void main(){ auto a= new test!int(); a.add(0); a.add(1); } class test(T){ void

Re: Shouldn't the pointers be different

2015-01-07 Thread Nick via Digitalmars-d-learn
On Wednesday, 7 January 2015 at 10:56:07 UTC, bearophile wrote: Nick: The two nodes have the same address, is this right? What you are printing is the address of the reference in the stack frame of add(). If you want to print the reference you can use this: import std.stdio; class