When I pass a function as an indicator (pointing to an object) as a parameter, then Copy the properties of the object? Is there no such practical reason, why not?
For example, if x is an indicator for object, the function is not visible for the assignment x = y calling function within the called function. However, assignment xf = 3 is visible (f is a feature).
Thank you!
is an indicator (in C and C ++ and most other languages) which is an address in memory Indicates where the real object remains.
- Assigning an indicator to another just copies that address from one pointer to another, passing the pointer
p
to a function, where the corresponding parameterX
The result points to the same address / object in two addresses: Calling function (p
) and in the one called (x
) Is one, but you have only one item (obj1
). - Now, in
xf = 3
(orc-> gtc: f = 3
in C / C ++ syntax), meaning "Object" Key X ". As it is the same object, indicatingp
, you can also see that change through thep
. - However, when you have another indicator inside the
Y
function that points to a different object (obj2
), and you Specify the pointer in x, you do not copy obj2's content to obj1, but you are only copying obj2 to ADDRESS inx
and obj1 unchanged. Now indicates an object object in comparison tox
top
, and as a result you do not later change any change afterp
Will be able to see
No comments:
Post a Comment