Aniket_Goku

copy constructer

Jun 28th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. //
  2. #include<stdio.h>
  3. #include<conio.h>
  4. #include<iostream.h>
  5. class demo
  6. {
  7. long int n1,n2;
  8. public:
  9. demo(long int x)
  10. {
  11. n1=x;
  12.  
  13. }
  14. demo(demo &a1,demo &a2)
  15. {
  16. cout<<"\n======================================";
  17. if(a1.n1==a2.n1)
  18. {
  19. cout<<"\n BOTH numbers are SAME";
  20. }
  21. else
  22. {
  23. if(a1.n1>a2.n1)
  24. {
  25. cout<<"\nBig number is ==> "<<a1.n1;
  26. }
  27. else
  28. {
  29. cout<<"\nBig number is ==> "<<a2.n1;
  30. }
  31. }
  32.  
  33. }
  34. void dis()
  35. {
  36. cout<<"\n ===============";
  37. cout<<"\n n1 ==> "<<n1 ;
  38.  
  39. }
  40.  
  41. };
  42.  
  43. int main()
  44. {
  45.  
  46. long int a,b;
  47.  
  48. clrscr();
  49. cout<< "\nobj a1: Enter number 1 => ";
  50. cin>>a;
  51.  
  52. cout<< "\n\nobj a2: Enter number 1 => ";
  53. cin>>b;
  54. //call of obj a1
  55. demo a1(a);
  56.  
  57. //call of obj a2
  58. demo a2(b);
  59.  
  60. cout<<"\na1 object's output";
  61. //call of display obj a1
  62. a1.dis();
  63.  
  64. cout<<"\n\na2 object's output";
  65. //call of display obj a2
  66. a2.dis();
  67.  
  68. //call of obj a3
  69. demo a3(a1,a2);
  70.  
  71. getch();
  72.  
  73. return 0;
  74. }
Add Comment
Please, Sign In to add comment