c++ record- 12) Hybrid Inheritance note:- 2nd year b.com 3sem record

 

  1. #include <iostream>  
  2. using namespace std;  
  3. class A  
  4. {  
  5.     protected:  
  6.     int a;  
  7.     public:  
  8.     void get_a()  
  9.     {  
  10.        std::cout << "Enter the value of 'a' : " << std::endl;  
  11.        cin>>a;  
  12.     }  
  13. };  
  14.   
  15. class B : public A   
  16. {  
  17.     protected:  
  18.     int b;  
  19.     public:  
  20.     void get_b()  
  21.     {  
  22.         std::cout << "Enter the value of 'b' : " << std::endl;  
  23.        cin>>b;  
  24.     }  
  25. };  
  26. class C   
  27. {  
  28.     protected:  
  29.     int c;  
  30.     public:  
  31.     void get_c()  
  32.     {  
  33.         std::cout << "Enter the value of c is : " << std::endl;  
  34.         cin>>c;  
  35.     }  
  36. };  
  37.   
  38. class D : public B, public C  
  39. {  
  40.     protected:  
  41.     int d;  
  42.     public:  
  43.     void mul()  
  44.     {  
  45.          get_a();  
  46.          get_b();  
  47.          get_c();  
  48.          std::cout << "Multiplication of a,b,c is : " <<a*b*c<< std::endl;  
  49.     }  
  50. };  
  51. int main()  
  52. {  
  53.     D d;  
  54.     d.mul();  
  55.     return 0;  
  56. }  


output:-








Comments

Popular posts from this blog

digital marketing ppt-u1

SOFTWARE

cn lab

Computer Operations and Performing - D L Unit-1-1

DS-Record-mca-04) write a program for evaluating a given postfix expression using stack.

DBMS Degree Lab Records

Unit 2: Foundations of Ownership, Security Related Concepts in Blockchain

Unit-1 Foundations of Software Systems and Blockchain

Access the Internet to Browse Infromation & E-Mail Operation- D L Unit-2-1

6)what are the various service of internet and protocols ICT-unit-1