摘要:
括号法 就是直接用普通函数的调用方式 #include<iostream> #include<string> using namespace std; class Student { private: int age; int *height; public: Student(int age1, i 阅读全文
posted @ 2020-09-24 23:23
磊神加特林
阅读(2645)
评论(0)
推荐(0)
摘要:
如果类中的某个属性是指针,且该指针指向的是一个堆 当创建一个新的类,而且拷贝构造函数默认时或者是直接的赋值,那两个类的该属性就指向同一个地址,当在析构函数中加入删除堆的操作时,会报错 #include<iostream> #include<string> using namespace std; c 阅读全文
posted @ 2020-09-24 22:21
磊神加特林
阅读(158)
评论(0)
推荐(0)
摘要:
当只设置了有参构造函数时,编译器会默认不再有无参构造函数和析构函数,但是有拷贝构造函数 #include<iostream> #include<string> using namespace std; class Student { private: int age; public: Student 阅读全文
posted @ 2020-09-24 21:51
磊神加特林
阅读(162)
评论(0)
推荐(0)

浙公网安备 33010602011771号