c++问题求大佬解决

2025-06-23 02:59:05
推荐回答(1个)
回答1:

#include
using namespace std;
/* 请在这里填写答案 */
class Student
{
public:
Student(int no, int score) :m_No(no), m_score(score)
{
count++;
}
Student(const Student& s)
{
this->m_No = s.m_No + 1;
this->m_score = s.m_score;
count++;
}
~Student()
{
count--;
}
void display()
{
cout << m_No << " " << (m_score ? "Pass" : "Fail") << endl;
}
static int count;
private:
int m_No;
int m_score;
};
int Student::count = 0;
int main(){
const int size = 100;
int i, N, no, score;
Student *st[size];
cin >> N;
for (i = 0; i{
cin >> no;
if (no>0)
{
cin >> score;
st[i] = new Student(no, score);
}
else
st[i] = new Student(*st[i - 1]);
}
cout << Student::count << " Students" << endl;
for (i = 0; ist[i]->display();
for (i = 0; idelete st[i];
return 0;
}