Write a C++ Program using concept of single Inheritance.


SUBMITTED BY: Nrupeshsinh

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

FORMAT: C++

SIZE: 360 Bytes

HITS: 495

  1. # include<iostream.h>
  2. # include<conio.h>
  3. class A
  4. {
  5. public:
  6. int a,b;
  7. void show()
  8. {
  9. cout<<"Enter value of A=";
  10. cin>>a;
  11. cout<<"Enter value of B=";
  12. cin>>b;
  13. }
  14. };
  15. class B : public A
  16. {
  17. public:
  18. void display()
  19. {
  20. cout<<"Sum="<<a+b;
  21. }
  22. };
  23. void main()
  24. {
  25. clrscr();
  26. B obj;
  27. obj.show();
  28. obj.display();
  29. getch();
  30. }

comments powered by Disqus