C++程序设计:设计一个学生类Student,有私有数据成员:学号,姓名,数学成绩,英语成绩,计算机成绩,静 5
3个回答
展开全部
把问题补充完整再问吧
class Student
{
int SNO;
string name;
int math;
int english;
int computer;
}
class Student
{
int SNO;
string name;
int math;
int english;
int computer;
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <iostream>
#include <string>
using namespace std;
class student
{
private:
string sno;
string sname;
double math;
double computer;
double avg;
double eng;
public:
student(string a,string b,double d,double e,double f);
student();
~student();
void setavg();
void show();
};
student::student(string a,string b,double d,double e,double f)
{
sno=a;
sname=b;
math=d;
computer=e;
eng=f;
}
student::student(){}
student::~student(){}
void student::setavg()
{ avg=(math+computer+eng)/3;}
void student::show ()
{ cout<<"sno="<<sno<<" ";
cout<<"sname="<<sname<<" ";
cout<<"math="<<math<<" ";
cout<<"computer="<<computer<<" ";
cout<<"eng="<<eng<<" ";
cout<<"avg="<<avg<<" ";
cout<<endl;
}
void main(void)
{
student s1("1001","abc",78,90,96);
student s2("1002","def",89,79,83);
student s3("1003","ghi",79,87,90);
s1.setavg ();
s1.show ();
s2.setavg ();
s2.show ();
s3.setavg ();
s3.show ();
}
#include <string>
using namespace std;
class student
{
private:
string sno;
string sname;
double math;
double computer;
double avg;
double eng;
public:
student(string a,string b,double d,double e,double f);
student();
~student();
void setavg();
void show();
};
student::student(string a,string b,double d,double e,double f)
{
sno=a;
sname=b;
math=d;
computer=e;
eng=f;
}
student::student(){}
student::~student(){}
void student::setavg()
{ avg=(math+computer+eng)/3;}
void student::show ()
{ cout<<"sno="<<sno<<" ";
cout<<"sname="<<sname<<" ";
cout<<"math="<<math<<" ";
cout<<"computer="<<computer<<" ";
cout<<"eng="<<eng<<" ";
cout<<"avg="<<avg<<" ";
cout<<endl;
}
void main(void)
{
student s1("1001","abc",78,90,96);
student s2("1002","def",89,79,83);
student s3("1003","ghi",79,87,90);
s1.setavg ();
s1.show ();
s2.setavg ();
s2.show ();
s3.setavg ();
s3.show ();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
class student
{
private string sno;
private string sname;
private int math_score;
private int english_score;
private int computer_score;
}
{
private string sno;
private string sname;
private int math_score;
private int english_score;
private int computer_score;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询