Home > Back-end > Questions about the argument structure pointer to do
Questions about the argument structure pointer to do
Time:12-01
Why structure pointer argument can't do here, with its address by value,,,
CodePudding user response:
Because this parameter is to require a passing parameters, if it's just a incoming parameters, is not to need to pass its address, if you want to put the P application space of the chain to the rear, you need to pass the address of the rear, this will have the right to modify the Attach with rear function, is to ensure that Attach to modify the rear in the calling function, rather than the Attach the parameter in the function,
CodePudding user response:
This belongs to the common problems, lz if understand the value of the argument (structure parameters) and pass the address of the argument (pointer parameter), the difference between that should understand, If by value, modify the parameter in a function is a function does not affect the outside of the argument (because the parameter is a copy of the argument, belongs to the different function of the stack memory space, both in addition to the same value without any connection), it should be the basic knowledge of the most basic, isn't it? So to modify function outside the argument? That is using a pointer passed argument addresses (such parameters and arguments to address is the same, that there was a link can change influence one another), So, you want to be in the Attach revise pRear makes function outside rear argument also affected, that is about to pass the address of the rear (that is, to use a pointer type or a reference type)