#include <iostream>
#include<cstring>
using namespace std;
class Student
{
private:
int id;
char name[20];
int age;
int tall;
public:
Student (int a,char nam[20],int c,int d )
{
id=a;
age=c;
tall=d;
for(int i=0;i<=20;i++)
{
name[i]=nam[i];
}
}
void display()
{cout<<"学号:"<<id<<endl;
cout<<"姓名:"<<name<<endl;
cout<<"年龄:"<<age<<endl;
cout<<"身高:"<<tall<<endl;
}
};
int main()
{
Student stu1(02,"chenhuaqing",20,170);
stu1.display();
return 0;
}
#include<cstring>
using namespace std;
class Student
{
private:
int id;
char name[20];
int age;
int tall;
public:
Student (int a,char nam[20],int c,int d )
{
id=a;
age=c;
tall=d;
for(int i=0;i<=20;i++)
{
name[i]=nam[i];
}
}
void display()
{cout<<"学号:"<<id<<endl;
cout<<"姓名:"<<name<<endl;
cout<<"年龄:"<<age<<endl;
cout<<"身高:"<<tall<<endl;
}
};
int main()
{
Student stu1(02,"chenhuaqing",20,170);
stu1.display();
return 0;
}