⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 11-6.cpp

📁 vc++的实验和实训例子非常适合初学者学习和阅读
💻 CPP
字号:
#include<iostream.h>
#include<iomanip.h>
const int MAX=80;
class person
{
private:
   char name[MAX],id[MAX];
   char sex[6];
public:
   void getdata()
   {
      cout<<"\n Input Name:";
      cin>>name;
      cout<<"Certificate No :";
      cin>>id;
      cout<<"Sex:";
      cin>>sex;
    }
    void dispdata()
    {
      cout<<"\n Certificate No:"<<id;
      cout<<"\n Sex:"<<sex;
     }
    void dispname()
    {cout<<setw(8)<<name;}
};
class student:public person
{
private:
   char tel[MAX];
   char sno[12];
public:
   void getdata()
   {
   person::getdata();
   cout<<"Input Telphone No:";cin>>tel;
   cout<<"Input Student No:";cin>>sno;
   }
   void dispdata()
   {
    person::dispdata();
 
    cout<<"\n Telphone No:"<<"\t"<<tel;
    cout<<"\n Student No:"<<"\t"<<sno;
   }
   void dispname()
   {person::dispname();}
};
class teacher:public person
{
private:
   char title[MAX],dep[MAX];
public:
  void getdata()
  {
   person::getdata();
   cout<<"Input Title:";cin>>title;
   cout<<"Input Department:";cin>>dep;
  }
  void dispdata()
  {
   person::dispdata();
   cout<<"\n The title of a technical:"<<"\t"<<title;
   cout<<"\n Department:"<<"\t"<<dep;
  }
  void dispname()
  {person::dispname();}
};
void main()
{
   student stul; 
   teacher teal;
   cout<<"\n Input data for student:";
   stul.getdata();
   cout<<"Input data for teacher:";
   teal.getdata();
   cout<<"Data on student:";
   stul.dispname();
   stul.dispdata();
   cout<<"\n Data on teacher:";
   teal.dispname();
   teal.dispdata();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -