Write a C++ program using concept of constructor overloading.


SUBMITTED BY: Nrupeshsinh

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

FORMAT: C++

SIZE: 438 Bytes

HITS: 536

  1. # include<iostream.h>
  2. # include<conio.h>
  3. class myclass
  4. {
  5. public:
  6. int a,b;
  7. myclass()
  8. {
  9. a=10;
  10. b=20;
  11. }
  12. myclass(int a1)
  13. {
  14. a=a1;
  15. b=30;
  16. }
  17. myclass(int a1,int b1)
  18. {
  19. a=a1;
  20. b=b1;
  21. }
  22. void put()
  23. {
  24. cout<<"A="<<a<<endl;
  25. cout<<"B="<<b<<endl;
  26. }
  27. };
  28. void main()
  29. {
  30. clrscr();
  31. myclass m1;
  32. myclass m2(40);
  33. myclass m3(50,60);
  34. m1.put();
  35. m2.put();
  36. m3.put();
  37. getch();
  38. }

comments powered by Disqus