#include<iostream.h>
class student
{
private :
int id;
float chinese,math,english;
public :
student();
student(int m_id,float m_chinese,float m_math,float m_english);
void show();
};
//无参数构造函数的定义,初始化各属性;
student::student()
{id=0;
chinese=english=math=0;
}
//有参数构造函数的定义,初始化各属性;
student::student(int m_id,float m_chinese,float m_math,float m_english)
{
id=m_id;
chinese=m_chinese;
math=m_math;
english=m_english;
}
void student::show()
{
cout<<id<<endl;
cout<<chinese<<endl;
cout<<english<<endl;
}
int main()
{
student s1(1001,100,98,87);
s1.show();
student s2(s1);
s2.show();
return 0;
}
11万+

被折叠的 条评论
为什么被折叠?



