定义一个成绩(score)类,包含私有数据成员数学课成绩(maths)、公有成员函数setscor

2025-05-22 04:48:43
推荐回答(3个)
回答(1):

不知道你是Java还是C++

我先写C++的写法:
#include
using namespace std;

class score

{
public:

score();
~score();
private:
int maths;

public:
void setscore(int _maths)
{
maths=_maths;

}
void printscore()
{
cout<
}
};

int main()
{
score *stu1=new score();
score *stu2=new score();

stu1->setscore(78);
stu2->setscore(91);
stu1->printscore(78);
stu2->printscore(91);
delete stu2;
delete stu1;
return 0;

}

回答(2):

v个以巨额冬天相符合代发货

回答(3):

什么语言?