拷贝构造和赋值函数(pushback调用拷贝构造函数)

拷贝构造和赋值函数(pushback调用拷贝构造函数)

pushback并非调用赋值函数,而是调用拷贝构造函数
RoleBasicInfo & operator =(const RoleBasicInfo & tmprolebasicinfo);
(非 RoleBasicInfo & operator =(RoleBasicInfo & tmprolebasicinfo);)
db_friend_t::db_friend_t(const db_friend_t & tmpdftinfo);

推测强制类型转换调用的也是拷贝构造,结束时析构.

class A
{}

A a;
A b = a;//拷贝构造函数;
A c;
c = a; //赋值函数;
所以写赋值函数时顺便写拷贝构造函数.

A a;
A b;
b = (A)a;
先copy构造一个,然后用赋值赋给b
http://www.vckbase.com/document/viewdoc/?id=1532

你可能感兴趣的:(拷贝构造和赋值函数(pushback调用拷贝构造函数))