我有一个程序 Student 。OOP Student ,我编写了构造函数,但我不知道如何析构 Student 因为我使用 string 而不是 char* 作为学生姓名
这是我的课。构造函数已经运行。你能帮我写析构函数吗?因为学生姓名数据类型是字符串所以我不能使用delete[]this->m_Sname.
class Student {
private:
string m_Sname; //Student Name
double m_SMathPoint; //Student Math Point
double m_SLiPoint; //Student Literature Point
public:
Student(string, double, double); //Initialize a student with name, math, literature points
Student(string); //Initialize a student with name, math = literature = 0.
Student(const Student& s); //Initialize a student from another student
~Student(); //Depose a student without memory leak
void printStudent();
};
Run Code Online (Sandbox Code Playgroud)