Struct pointers are useful and reliable, but before using them
you need to know the difference between heap and stack, what a
stack frame is, and how structs are handled when they are on
the stack. Learning the basics of such things ideas requires
only few minutes and it will be useful for many
deed:
Meaning struct pointers are unusable or at least highly
unreliable?
Struct pointers are useful and reliable, but before using them
you need to know the difference between heap and stack, what a
stack frame is, and how structs are handled when they are on the
stack. Learning the basics
On Wed, Oct 10, 2012 at 12:59:08AM +0200, deed wrote:
> On Tuesday, 9 October 2012 at 16:21:47 UTC, bearophile wrote:
> >deed:
> >
> >> // Again, why are the three last adresses the same?
> >
> >The D language and its compiler is acting correctly here, so the
> >output you see is correct. All
On Tuesday, 9 October 2012 at 16:21:47 UTC, bearophile wrote:
deed:
// Again, why are the three last adresses the same?
The D language and its compiler is acting correctly here, so
the output you see is correct. All those structs are allocated
on the stack. The first three Test are a
deed:
// Again, why are the three last adresses the same?
The D language and its compiler is acting correctly here, so the
output you see is correct. All those structs are allocated on the
stack. The first three Test are allocated on the stack. In the
loop it allocates the first str
import std.stdio;
struct Test
{
static Test[] objects;
static Test*[] psObject;
static int[] ints;
static int*[] psInt;
int a;
int b;
int* pa;
this(int a)
{
this.a = a;
this.pa = &this.a;
this.b = 2 * a;