#include <iostream>
#include<iomanip>
using namespace std;
class Student
{
private:
int id;
char name[20];
double high;
double weight;
public:
void inputStudent()
{
cout<<"请输入学号: ";
cin>> id;
cout<<"请输入名字: ";
cin>>name;
cout<<"请输入身高: ";
cin>>high;
cout<<"请输入体重: ";
cin>>weight;
}
void showStudent( )
{ cout<<"学号"<<setw(6)<<"姓名"<<setw(12)<<"身高"<<setw(18)<<"体重"<<endl;
cout<<" " <<id<<" "<<name<<" " <<high<<" " <<weight<<endl;
}
};
int main()
{
Student stu1;
stu1.inputStudent();
stu1.showStudent( ) ;
return 0;
}
学生类的定义
最新推荐文章于 2021-04-20 23:31:42 发布