摘要: #include <iostream>#include <string>using namespace std;class pt{public: pt(int a,int b){this->x=a,this->y=b;} int getX() const {return this->x;} //此处 阅读全文
posted @ 2018-01-13 21:18 Dart2100 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 必要性(作用):释放指针,释放资源 例如: class Student{ public: Student(){m_name=new char[20];} //即在堆上定义 故在释放对象时必须要释放掉内存 private: char *m_name; }; 故需要添加析构函数: //销毁时自动调用,没 阅读全文
posted @ 2018-01-13 09:31 Dart2100 阅读(2400) 评论(0) 推荐(0) 编辑
摘要: 例如类: class Student{ public: Student(){ cout<<"student"<<endl; } }; 定义:Student stu1; //这个三个实例化中,只有第一个会打印student,即执行构造函数 Student stu2=stu1; //另外的两个执行的是拷 阅读全文
posted @ 2018-01-13 09:01 Dart2100 阅读(576) 评论(0) 推荐(0) 编辑