Copy, Assign and Destroy in C++

Several important concepts: copy constructor, copy assignment operator; copy initialization, direct initialization


As shown in the figure, there are two "copy constructors".

Direct initialization of an object is performed by directly calling the constructor (including the copy constructor) to initialize the object.

Using the assignment operator, calling a function by value, a function returning a non-reference object, initializing with a braced list, and insert and push_back of standard library containers are all copy-initialized.

Copy initialization is usually done using the copy constructor.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325867121&siteId=291194637