C++代码

来源:互联网 发布:淘宝店铺权重提升 编辑:程序博客网 时间:2024/06/09 14:40

#include<string.h>

#include<iostream>

using namespace std;

class fire

{

 protected:

   char name[20];

   int age;

   char sex;

   char address[20];

   long tel;

 public:

   fire()

   {

     strcpy(name,"fire");

age=18;

sex='m';

strcpy(address,"dd86749");

tel=2410421;

   }

   void print()

   {

    cout<<name<<","<<age<<","<<sex<<","<<address<<","<<tel<<endl;

   }

};

class tiaotan: protected fire

{

 protected:

  char department[20];

  float salay;

 public:

  tiaotan():fire()

  {

   strcpy(department,"Computer");

   salay=2010.34f;

  }

  void print()

  {

  cout<<name<<","<<age<<","<<sex<<","<<address<<","<<tel;

  cout<<","<<department<<","<<salay<<endl;

  }

};

int main()

{

tiaotan zwj;

zwj.print();

}