Home > Back-end >  Want to ask, every c copy function problem
Want to ask, every c copy function problem

Time:11-07

C + + copy function that a knowledge that, if the function of the return is a kind of object, then he will automatically copy function called in what function,
(1) to define A class A
A f ()
{
A, A.
Return a;
}
A, b.
B=f ();
This time will automatically copy, if such A function definition in brackets are the object of the class, that is called?
As A f (c) this kind of situation,

CodePudding user response:

If there is no definition copy function, will generate the default copy function

CodePudding user response:

1. If there is no return value type belt & amp; , copy is invoked structure, best oneself write a test a try,
In addition, belt & amp; Return values, must ensure that its life cycle at the end of the function exists, the

2. The above function parameters, without & amp; Called, is the value, will make a copy,
Next:notes
  • Related