摘要:
Copy and Swap idiom使用到著名的Big three中兩個特殊的成員函數(拷貝構造函數copy construction與賦值構造函數assignment constrcution). 作用在于在深拷贝的过程中保证强异常的作用,具体代码如下class Person
{
public: Person(int id, const char * pszName):_id(id), _pszName(new char[strlen(pszName) + 1]){strcpy(_pszName, pszName);} Person():_id(0) { _pszName = n... 阅读全文
posted @ 2012-11-20 19:58 Roger Luo 阅读(823) 评论(0) 推荐(0) 编辑