References

David Currie curriedr at iinet.net.au
Mon Nov 28 17:41:08 PST 2011


I am a newbie to D. From (C++,Java,others...) background.

In C++ I can say

void f1(int& pInt)
{
   pInt = 1;
}

which sets pInt(which is outside f1)
because although pInt (at compile time) is a Value
in reality it is passed by reference(address).

Now

void f2(int* pIntPtr)
{
   *pIntPtr = 1;
   ++pIntPtr;
   *pInt   = 2;
}
sets (the contents of) pInt to 1 (and the next immediate address to 2)

All this is of course standard C++.

How is this type of thing done in D
(changing objects by passing by reference etc)?







More information about the Digitalmars-d-learn mailing list