By calling fn in C ++, args are copied to the corresponding parameter. Is this initialization or assignment?

in a function call in C ++, the arguments are copied to the corresponding parameter. Is this initialization or assignment?

+4
source share
3 answers

The missing semantics of the argument is initialization. The meaning will be to call the copy / move constructors of your classes.

+7
source

Then the arguments are copied by value (i.e., initialization).

+1
source

Initialization: (please check the original project )

5.2.2 function call

When a function is called, each parameter must be initialized with the corresponding argument. [Such initializations are vaguely ordered relative to each other]. When a function, parameters that have an object type, must have a fully defined object type. [this still allows the parameter to be a pointer or a reference to an incomplete class type. However, it prevents the pass-by-value parameter from being an incomplete class type.] During parameter initialization, an implementation can avoid creating additional time series by combining the transformations with the associated argument and / or constructing parameter initialization times. The lifetime of the parameter ends when the function in which it is defined returns. The initialization and destruction of each parameter occurs in the context of the function call. [access to the constructor, conversion function, or Destructor is checked at the point of call in the calling function. If the constructor or destructor for the function parameter throws an exception, the search for the handler begins in the function call area; in particular, if the called function has a function-try-block with a handler that could handle the exception, this handler is not considered.]

0
source

All Articles