C # has been used more, and has recently returned to C ++ programming. Some fatal differences are found. If you do not pay attention to them, some inexplicable bugs may occur. The reference type is one of them.
In C #, references are similar to pointers, except for the value type (INT, float, struct, etc. It is a variable on the stack. It points to a specific instance on the stack and can be changed at will.
In C ++, a reference is just an alias of a variable. It needs to point to an instance during initialization, and then its operation is equivalent to modifying the original Instance. In most cases, it is possible to change the reference usage like C:
Classa a1, a2;
Classa & A = A1;
A = A2;
Do not think that A is now a reference of A2. The last sentence is to assign the value of A2 to A1!
I would like to dedicate this article to C #'s proficiencyProgramEmployee