摘要: 构造动态变量进行*m_pi = *that.m_pi /* 自定义的深拷贝 */ #include <iostream> using namespace std; class Integer{ public: Integer(int i) { m_pi = new int; //使用new int 阅读全文
posted @ 2020-04-02 19:28 c语言我的最爱 阅读(927) 评论(0) 推荐(0) 编辑
摘要: 使用析构函数,进行函数的删除 /* 析构函数 */ #include <iostream> using namespace std; class Integer { public: Integer(int i) { m_pi = new int; *m_pi = i; } ~Integer(void 阅读全文
posted @ 2020-04-02 19:16 c语言我的最爱 阅读(237) 评论(0) 推荐(0) 编辑
摘要: 使用const进行函数的定义 /* 使用const进行定义 */ #include <iostream> using namespace std; class A{ public: A(int i = 0):m_data(i) {} void print(void) const { //const表 阅读全文
posted @ 2020-04-02 19:12 c语言我的最爱 阅读(1309) 评论(0) 推荐(0) 编辑
摘要: 使用this可以用来表示当前类的变量 /* string 字符串 */ #include <iostream> #include <cstring> using namespace std; class String { public: String(const char* str) { m_str 阅读全文
posted @ 2020-04-02 18:37 c语言我的最爱 阅读(310) 评论(0) 推荐(0) 编辑