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


SUBMITTED BY: Nrupeshsinh

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

FORMAT: C++

SIZE: 395 Bytes

HITS: 466

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

comments powered by Disqus