Android Ndk 学习笔记(目录)
class Kaobei{
public:
int age;
char * name;
Kaobei() { cout << "空参数构造函数" << endl; }
Kaobei(char * name) :Kaobei(name, 99) {
cout << "一个参数构造函数 this:" << this << endl;
}
Kaobei(char * name, int age) {
cout << "二个参数构造函数 this:" << this << endl;
this->name = (char *)malloc(sizeof(char *)* 10);
strcpy(this->name, name);
this->age = age;
}
~Kaobei() {
cout << "析构函数执行 &this->name:" << this->name << endl;
free(this->name);
this->name = NULL;
}
Kaobei(const Kaobei & stu) {
cout << "拷贝构造函数 &stu:" <<&stu << " this:" <<this << endl;
this->name = (char *)malloc(sizeof(char *)* 10);
strcpy(this->name, name);
this->age = stu.age;
cout << "拷贝构造函数2 this->name:" << this->name << " stu.name:" << stu.name << endl;
}
};