04 2020 档案
摘要:构造动态变量进行*m_pi = *that.m_pi /* 自定义的深拷贝 */ #include <iostream> using namespace std; class Integer{ public: Integer(int i) { m_pi = new int; //使用new int
阅读全文
摘要:使用析构函数,进行函数的删除 /* 析构函数 */ #include <iostream> using namespace std; class Integer { public: Integer(int i) { m_pi = new int; *m_pi = i; } ~Integer(void
阅读全文
摘要:使用const进行函数的定义 /* 使用const进行定义 */ #include <iostream> using namespace std; class A{ public: A(int i = 0):m_data(i) {} void print(void) const { //const表
阅读全文
摘要:使用this可以用来表示当前类的变量 /* string 字符串 */ #include <iostream> #include <cstring> using namespace std; class String { public: String(const char* str) { m_str
阅读全文