SHARE
TWEET

Untitled

a guest Jun 25th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A {
  5. protected:
  6. int x;
  7. public:
  8. A(int a):x(a){}
  9. };
  10.  
  11. class B: virtual public A {
  12. protected:
  13. int x;
  14. public:
  15.  
  16. B(int a, int b):A(a),b(x){}
  17.  
  18.    
  19. };
  20.  
  21. class C: virtual public A {
  22. protected:
  23. int x;
  24. public:
  25. C(int a, int c):A(a),c(x){}
  26. };
  27.  
  28. class D: public B,C {
  29. protected:
  30. int x;
  31. public:
  32. D(int a, int b, int c,int d):A(a),B(b),C(c),d(x){}
  33.  
  34. };
  35.  
  36. class E: public D {
  37. protected:
  38. int x;
  39. public:
  40. E(int a, int b, int c, int d, int e):D(a,b,c,d),e(x){}
  41. friend ostream&operator<<(ostream& os, const E&obj){
  42. os << obj.A::x << " " << obj.B::x
  43. << " " <<obj.C::x << " "  << obj.D::x << " " << x << " ";
  44. return os;
  45. };
  46.  
  47.  
  48. int main(){
  49.  
  50. E a(1,2,3,4,5);
  51.  cout << a << endl;
  52.    return 0;
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top