still confused about call by reference

Bill Baxter dnewsgroup at billbaxter.com
Tue Oct 30 18:46:19 PDT 2007


Saaa wrote:
> What does this mean exactly ?
> 
> initialize an instance of a struct on the heap
> without factoring out the initialization to _another_ function

You can say
   MyStruct *x = new MyStruct;

But even with a static opCall defined, this doesn't work
   MyStruct *x = new MyStruct(a,b,c);

You have to do something like:
   MyStruct *x = new MyStruct;
   *x = MyStruct(a,b,c);

Or that's what I guess he means, at least.  I haven't actually tried the 
code above to see what it will do.

--bb


More information about the Digitalmars-d-learn mailing list