Subscribe Us

Responsive Advertisement

Advertisement

Single Inheritance :: private c++ OOP

 

Single Inheritance :: private c++ OOP



#include<bits/stdc++.h>

using namespace std;

class A

{

    int a;

public:

    int b;

    void get()

    {

        int x,y;

        cin>>x>>y;

        a=x;

        b=y;

    }

    int get_a()

    {

        return a;

    }


};

class B:private A

{

    int c;

public :

    void mul()

    {

        get();

        c=get_a()*b;

    }

    void show()

    {

        cout<<c<<endl;

    }

};

int main()

{

    B b;

    b.mul();

    b.show();


    return 0;

}


Post a Comment

0 Comments