作业社区
探索学习新天地,共享知识资源!
奋斗中的小沫 的学生作业:
#include #include #include #include using namespace std; class Student { private: char* name; int age; static Student* instance; Student(const char* name, int age) { this->age = age; char* p = (char*)name; while (*p++); int len = p - name; this->name = (char*)malloc(len * sizeof(char)); strcpy(this->name, name); } public: static Student* static_func(const char* name, int age) { if (Student::instance == NULL) { Student::instance = new Student(name, age); } return Student::instance; } void show(void) const; ~Student(); }; Student* Student::instance = NULL; void Student::show(void) const { { cout
+77