锐单电子商城 , 一站式电子元器件采购平台!
  • 电话:400-990-0325

NEFU C++实验四派生类与继承(锐格)

时间:2022-12-26 20:30:00 101e电位器trimmer

5362、

题目内容:

可以输出以下程序ASCII修改以下程序,使字符与相应数字的对照表输出到字母z。

输入输出说明:

输出:每隔12个字母换行,设置输出的域宽为4 ASCII value-char    97a  98b  99c 100d 101e 102f    103g 104h 105i 106j 107k 108l  109m 110n 111o 112p 113q 114r  115s 116t 117u 118v 119w 120x  121y 122z
#include #include using namespace std; class  table{ public:     table (int p){         i=p;     }     void ascii(void); protected:     int i; }; void table ::ascii(){     int k=1;     for(;i<97 26;i  ){         cout<

5522、

题目内容:

下面的程序包Time类和Date类声明需要设计Birthtime类,它继承了Time类和Date还有一个出生孩子的名字Childname,同时设计主程序显示一个小孩的出生时间和名字。

输入输出说明:

输出: dcc 9:18:18 11/22/2007
#include  #include  using namespace std; class Time { public:     Time(int h, int m, int s)     {         hours = h;         minutes = m;         seconds = s;     }     void display()     {         cout << hours << ":" << minutes << ":" << seconds << endl;     }  protected:     int hours, minutes, seconds; }; class Date { public:     Date(int m, int d, int y)     {         month = m;         day = d;         year = y;     }     void display() { cout << month << "/" << day << "/" << year << endl; }  protected:     int month, day, year; }; class Birthtime : public Date,public Time { public:     Birthtime(char *m, int mon, int d, int y, int h, int min, int s) : Date(mon, d, y), Time(h, min, s)     {         Childname = m;     }     void display()     {         cout << Childname <

5531、

题目内容:

建立普通基类building,用于存储建筑物的层数、房间数及其总平方数。建立衍生物house,继承building,并存储卧室和浴室的数量。此外,建立衍生物office,继承building,并存储灭火器和电话号码。

输入输出说明:

定义house 对象给出的初8、4、32、4、600.0 定义building 对象给出的初始值分别为40、40、15、402000.0 输出: floor is 32 house is 4 square is 600 bedroom is 8 bathroom is 4 floor is 15 house is 40 square is 2000 extinguisher is 40 telephone is 40
#include  using namespace std; class building { protected:     int floor, house;     double squre;  public:     building(int floor, int house, double squre)     {         this->floor = floor;         this->house = house;         this->squre = squre;     }     void display()     {         cout << "floor is" << floor << "house is" << house << "square is" << squre << endl;     } }; class house1 : public building { protected:     int beedroom, bathroom;  public:     house1(int floor, int house, double squre, int beedroom, int bathroom): building(floor, house, squre)     {         this->bathroom = bathroom;         this->beedroom = beedroom;     }     void display()     {         cout << "floor is " << floor << " house is " << house << " square is " << squre << endl;         cout << "bedroom is " << beedroom << " bathroom is " << bathroom << endl;     } }; class office : public building { protected:     int extinguisher, telephone; public:     office(int floor, int house, double squre,int extinguisher,int  telephone):building(floor,house,squre){         this->extinguisher=extinguisher;         this->telephone=telephone;     }     void display(){         cout << "floor is " << floor << " house is " << house << " square is " << squre << endl;         cout <<"extinguisher is " <

 5532、

題目內容:

按照要求编写程序。说明person类:含有成员name和id;说明teacher类和student类,teacher类含有成员degree和dep,student类含有成员old和sno。这两个类继承person类;说明stud类,含有成员addr和tel;说明score类,含有成员math和eng。该类继承student类和stud类。定义属于类score的对象c1及类teacher的对象t1,分别输入各数据成员的值后再显示出这些数据。

输入输出说明:

输出:
name is dcc id is 23010620071122
old is 10 sno is 201304
addr is Haping Rord tel is 13804582160
math is 94 eng is 100
name is dbz id is 23010719750412
degree is Ph.D dep is computer
#include
using namespace std;
class person{
protected:
    string name;
    string id;
public:
    person(string name,string id){
        this->name=name;
        this->id=id;
    }
    void output(){
        cout<<"name is "<degree=degree;
        this->dep=dep;
    }
    void output(){
        person::output();
        cout<<"degree is "<old=old;
        this->sno=sno;
    }
    void output(){
        person::output();
        cout<<"old is "<tel=tel;
        this->addr=addr;
    }
    void output(){
        cout<<"addr is "<math=math;
        this->eng=eng;
    }
    void output(){
        student::output();
        stud::output(); 
        cout<<"math is "<
锐单商城拥有海量元器件数据手册IC替代型号,打造电子元器件IC百科大全!

相关文章