Write a C++ program using concept of hierarchical inheritance.


SUBMITTED BY: Nrupeshsinh

DATE: June 26, 2016, 4:18 a.m.

FORMAT: C++

SIZE: 452 Bytes

HITS: 444

  1. # include<iostream.h>
  2. # include<conio.h>
  3. class A
  4. {
  5. public:
  6. int a;
  7. void show()
  8. {
  9. a=10;
  10. cout<<"A="<<a;
  11. }
  12. };
  13. class B :public A
  14. {
  15. public:
  16. int b;
  17. void show1()
  18. {
  19. b=20;
  20. cout<<"B="<<b;
  21. }
  22. };
  23. class C : public A
  24. {
  25. public:
  26. int c;
  27. void show2()
  28. {
  29. c=30;
  30. cout<<"C="<<c;
  31. }
  32. };
  33. void main()
  34. {
  35. clrscr();
  36. B obj;
  37. C obj1;
  38. obj.show();
  39. obj.show1();
  40. obj1.show2();
  41. getch();
  42. }

comments powered by Disqus