Home > Back-end >  C cout <problem, ask for help!
C cout <problem, ask for help!

Time:09-30

Function as shown, why executive function A (A), if use cout connected output, the value of A constant, separate output, A value can change? Thank you all!



CodePudding user response:

Right to left, elimination,

CodePudding user response:

Execute the right to do, the output is left and right

CodePudding user response:

Generally from right to left, but the best don't many times in the same expression, a deal with a variable

CodePudding user response:

reference Italink reply: 3/f
generally from right to left, but the best don't be an expression of multiple processing a variable


This expression is evaluation order problems, there is no "general from right to left, the detailed instructions are included in the c + + standard, so the first picture cout... The behavior is undefined,
Evaluated the building Lord, order a lot of rules, simply speaking, such as in an expression (accuracy is evaluated in the same point) in The Times the same variable, you need to write separate,

CodePudding user response:

reference 4 floor coo135 response:
Quote: reference Italink reply: 3/f

Generally from right to left, but the best don't be an expression of multiple processing a variable


This expression is evaluation order problems, there is no "general from right to left, the detailed instructions are included in the c + + standard, so the first picture cout... The behavior is undefined,
Evaluated the building Lord, order a lot of rules, simply speaking, such as in an expression (accuracy is evaluated in the same point) in The Times the same variable, you need to write separately,

Uh huh, took down

CodePudding user response:

Speak in front of the solution is not A question, but have A doubt, the parameters of the function is what meaning, A biography and address again? If is the address of a transfer should be int * x a (& amp; A)?

CodePudding user response:

refer to 6th floor qq_1457346882 response:
the front say the solution is not A question, but have A doubt, the parameters of the function is what meaning, A biography and address again? If is the address of a transfer should be int * x a (& amp; A)?


Pass a. Value
In value transfer, is actually a copy the content of the argument to the parameter of the arguments and parameters are stored in two different memory space, the function of parameter in the body of all change has no effect on all the arguments;
2. If the parameter is the object of the class, pass by value every time call the constructor of a class object structure, efficiency is lower,
2. Pass Pointers (address)
1. When in the pointer parameter is a pointer variable, the argument is the address of a variable or a pointer variable, the function, parameter points to the address of the argument;
2. The pointer, function in the body can change the arguments by parameter pointer address space, the content of the
3. Transfer reference
1. The reference is, in fact, a certain variable aliases, and the variable with the same memory space;
2. The variable argument passed to the parameter references, is equal to the parameter is the alias of real depending on a parameter, the parameter changes are directly modify argument;
3. Often used in the class member functions of class reference object as a parameter, greatly improve the efficiency of the code,

CodePudding user response:

Trust is a simple
Code wrong undefined behavior results meaningless

CodePudding user response:

reference 5 floor Italink reply:
Quote: refer to 4th floor coo135 response:
Quote: reference Italink reply: 3/f

Generally from right to left, but the best don't be an expression of multiple processing a variable


This expression is evaluation order problems, there is no "general from right to left, the detailed instructions are included in the c + + standard, so the first picture cout... The behavior is undefined,
Evaluated the building Lord, order a lot of rules, simply speaking, such as in an expression (accuracy is evaluated in the same point) in The Times the same variable, you need to write separately,

Uh huh, took down


Add ha, c + + standard update soon ah ~ ~, starting from the c + + 17, the first kind of writing is legitimate, the result is the same, both
Because c + + 17, set the evaluation order of the shift operator: expression E1 & lt; Each value calculation of E2, E1 and side effects are in order before the E2 each value calculation and side effects,
  • Related