Sunday, February 25, 2018

C++ : Private Properties

#include <iostream>
using namespace std;
class M {
protected:
    int m;
public:
   void set_m(int x) { m = x; };
};
class N {
protected:
    int n;
public:
    void set_n(int y) { n = y; };
};
class P : public M, public N {
public:
    void display() { cout << m * n << endl; };
};

int main(){
    int a, b;
    cin >> a >> b;
    P p;



p.M::set_m(a);
p.N::set_n(b);
p.display ();
    return 0;
}  // End of main()

Thanks
Happy Computing !

No comments:

Post a Comment

Sacred Thought

28 April 2024 Today I am going to explain verse 31 - 38 chapter two for you all. There is no opportunity better than a righteous war (सत्य औ...