Click to See Complete Forum and Search --> : pointer_default


George2
February 13th, 2008, 01:57 AM
Hello everyone,


Could anyone show me the usage of pointer_default please (sample of when we need to use ref, unique and ptr)? After some search, I found too little materials on this topic. :-)


thanks in advance,
George

wildfrog
February 14th, 2008, 06:02 PM
The usage of pointer_default (http://msdn2.microsoft.com/en-us/library/aa367141(VS.85).aspx) is to specify which one of ptr (http://msdn2.microsoft.com/en-us/library/aa367149(VS.85).aspx), ref (http://msdn2.microsoft.com/en-us/library/aa367153(VS.85).aspx) or unique (http://msdn2.microsoft.com/en-us/library/aa367294(VS.85).aspx) that should be used by default (exept for parameters pointers which default to ref).

For an example check out Default Pointer Types (http://msdn2.microsoft.com/en-us/library/aa373628(VS.85).aspx).

- petter

George2
February 14th, 2008, 11:19 PM
Thanks petter,


I have some further issue for unique attribute after some study for the link you recommended.

http://msdn2.microsoft.com/en-us/library/aa367294(VS.85).aspx

(Especially confused about "before the call")

--------------------
Can use existing memory on the client without allocating new memory. When a unique pointer changes during a call from one non-NULL value to another, the pointer is assumed to point to a data object of the same type. Data returned from the server is written into existing storage specified by the value of the unique pointer before the call.
--------------------

I do not know why "Data returned from the server is written into existing storage specified by the value of the unique pointer before the call", especially "the value of the unique pointer before the call".

Suppose the following scenario,

1. client pass point ptr1 to server and ptr2 originally pointed to memory buffer1;
2. server change ptr1 to pointed to memory buffer2, which is different from buffer1;
3. server writes data through pointer ptr1, it should be written to buffer2.

So, it should be,

Data returned from the server is written into existing storage specified by the "lastest" value of the unique pointer, which is memory buffer 2.

Other than,

Data returned from the server is written into existing storage specified by the value of the unique pointer "before" the call, which is memory buffer 1.

Any comments?

The usage of pointer_default (http://msdn2.microsoft.com/en-us/library/aa367141(VS.85).aspx) is to specify which one of ptr (http://msdn2.microsoft.com/en-us/library/aa367149(VS.85).aspx), ref (http://msdn2.microsoft.com/en-us/library/aa367153(VS.85).aspx) or unique (http://msdn2.microsoft.com/en-us/library/aa367294(VS.85).aspx) that should be used by default (exept for parameters pointers which default to ref).

For an example check out Default Pointer Types (http://msdn2.microsoft.com/en-us/library/aa373628(VS.85).aspx).

- petter


regards,
George