# include
# include
using namespace std;
Int main ()
{
Auto p=make_shared & lt; Int> (42);//! Pointing to the object is only a reference, p
Cout & lt;
Cout & lt;
Cout & lt; <"-- -- -- -- -- -- -- -- -- afterAssin -- -- -- -- --" & lt;
Cout & lt; <* p & lt; <"==" & lt; <* q & lt;
Cout & lt;
Output:
1
1
-- -- -- -- -- -- -- -- -- afterAssin -- -
56==56
2
2
Please press any key to continue...
Question: why is the final output is 2 instead of 0
CodePudding user response:
Found the reason, p=q, q assigned to p, p, q point to the same reference, so it is 2CodePudding user response:
Right on the second floor