第六次实验

#include<iostream>
using namespace std;

class Pack
{
    public:
        void plus();
        Pack(int a,int b):m(a),n(b){}
        ~Pack(){}
        int getm(){return m;}
        int getn(){return n;}
    private:
        int m,n;
};

void Pack::plus()
{
    cout<<"the result of plus is:"<<m+n<<endl;
}

class A:public Pack
{
    public:
        A(int a,int b):Pack(a,b),p(a),q(b){}
        ~A(){}
        void min();
    private:
        int p,q;
};

void A::min()
{
    cout<<"the result of minus is:"<<p-q<<endl;
}

class B:public Pack
{
    public:
        B(int a,int b):Pack(a,b),j(a),k(b){}
        ~B(){}
        void mult();
    private:
        int j,k;
};

void B::mult()
{
    cout<<"the result of mult is:"<<j*k<<endl;
}

class C:public Pack
{
    public:
        C(int a,int b):Pack(a,b),y(a),h(b){}
        void div();
    private:
        int y,h;
};

void C::div()
{
    cout<<"the result of div is:"<<y/h<<endl;
}

int main()
{
    A a(2,6);
    B b(3,12);
    C c(1,5);

    a.plus();
    a.min();

    b.plus();
    b.mult();

    c.plus();
    c.div();
}

猜你喜欢

转载自www.cnblogs.com/705397046see/p/9152950.html