实验6

Posted -alone

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了实验6相关的知识,希望对你有一定的参考价值。

#include<iostream>
using namespace std;
class Add{
    public:
        Add(int x,int y):x(x),y(y){
        cout<<x+y<<endl;
    }
    private:
        int x,y;
};
class A:public Add{
    public:
        A(int x,int y):Add(x,y),x(x),y(y){}
        void jian(){cout<<x-y<<endl;}
    private:
        int x,y;
};
class B:public Add{
    public:
        B(int x,int y):Add(x,y),x(x),y(y){}
        void cheng(){cout<<x*y<<endl;}
    private:
        int x,y;
};
class C:public Add{
    public:
        C(int x,int y):Add(x,y),x(x),y(y){}
        void chu(){cout<<x/y<<endl;}
    private:
        int x,y;
};
int main()
{
    A a(2,3);
    a.jian();
    B b(5,4);
    b.cheng();
    C c(4,4);
    c.chu();
    return 0;
}

技术分享图片

#include<iostream>
using namespace std;
class vehicle{
    public:
        vehicle(int x,int y):maxspeed(x),weight(y){}
        void run(){cout<<"0"<<endl;}
        void stop(){cout<<"1"<<endl;}
    private:
        int maxspeed,weight;
};
class bicycle:public vehicle{
    public:
        bicycle(int x,int y,int z):vehicle(x,y),height(z){}
        void run(){cout<<"0"<<endl;}
        void stop(){cout<<"1"<<endl;}
    private:
        int height;
};
class motorcar:public vehicle{
    public:
        motorcar(int x,int y,int h):vehicle(x,y),seatnum(h){}
        void run(){cout<<"0"<<endl;}
        void stop(){cout<<"1"<<endl;}
    private:
        int seatnum;
};
class motorcycle:public vehicle,public bicycle,public motorcar{
    public:
        motorcycle(int x,int y,int z,int h):vehicle(x,y),bicycle(x,y,z),motorcar(x,y,h){}
        void run(){cout<<"0"<<endl;}
        void stop(){cout<<"1"<<endl;}
};
int main()
{
    vehicle a(4,5);
    a.run();
    a.stop();
    bicycle b(3,3,2);
    b.run();
    b.stop();
    motorcar c(2,2,3);
    c.run();
    c.stop();
    motorcycle d(1,1,2,2);
    d.run();
    d.stop();
    return 0;
}

技术分享图片

以上是关于实验6的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段6——CSS选择器

20155201 李卓雯 《网络对抗技术》实验一 逆向及Bof基础

缓冲区溢出漏洞实验 20199321

使用 React 实验性中继片段:缺少属性 '"$fragmentRefs"'

找到我的自定义代码片段 Xcode 6?

[NTUSTISC pwn LAB 6]rop&Return to plt实验