摘要:
//析构函数的调用//在一般情况下,调用析构函数的次序正好与调用构造函数的次序相反//最先被调用的构造函数,其对应的析构函数最后被调用.#include "stdafx.h"#include <iostream>using namespace std;class CPen{public: CPen(int size=10); ~CPen(); int GetSize(); int SetSize(int size); void Write();private: int m_size;};CPen::CPen(int size){ m_size = si... 阅读全文
摘要:
//复制构造函数#include "stdafx.h"#include <iostream>using namespace std;class CPen{private: int m_size;public: CPen(int size); CPen(CPen &pen); int GetSize(); void Write();};CPen::CPen(int size){ m_size = size;}CPen::CPen(CPen &pen){ m_size = pen.GetSize(); cout << "size 阅读全文