📄 10.5.cpp
字号:
#include <iostream.h>
#include <string.h>
class Student
{
public:
Student(int no,char *str,char s)
{
stuno=no;
strcpy(name,str);
sex=s;
cout<<"Constructor called.S\n";
}
void Print()
{
cout<<stuno<<'\t'<<name<<'\t'<<sex<<'\t';
}
private:
int stuno;
char name[20];
char sex;
};
class Student1:public Student
{
public:
Student1(int no,char *str,char s,int a,int sco):Student(no,str,s)
{
age=a;
score=sco;
cout<<"Constructor called.S1\n";
}
void Print()
{
Student::Print();
cout<<age<<'\t'<<score<<endl;
}
private:
int age,score;
};
void main()
{
Student1 s1(502001,"Ma li",'m',20,90),s2(502002,"Li hua",'f',19,88);
s1.Print();
s2.Print();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -