Advertisement
TechOPGOHIL

Untitled

Dec 3rd, 2023
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. // write a program to perform peramiterized constructor with single argument with implisit call and explisit call
  2. // write a program to perform peramiterized constructor with doubble argument with implisit call and explisit call
  3. #include<iostream.h>
  4. #include<conio.h>
  5. class om
  6. {
  7.     int a,b;
  8.     public:
  9.     om(int x)   // inside the class
  10.     {
  11.         a=x;
  12.         b=0;
  13.     }       //single peramiter
  14.     om(int x, int y); // doubble peramitersized constructor
  15.     // out side the class.
  16.     void display(); //out side class
  17. };
  18. om :: om (int x , int y)
  19. {
  20.     a=x;
  21.     b=y;
  22. }
  23. void om :: display()
  24. {
  25.     cout<<"A ="<<a<<endl;
  26.     cout<<"B ="<<b<<endl;
  27. }
  28.  
  29. void main()
  30. {
  31.     clrscr();
  32.     cout<<"\nImplisit 1 peramiter constructor called..\n";
  33.     om o(10);
  34.     o.display();
  35.     cout<<"\nExplisit 1  peramiter consructor called ..\n";
  36.     om o2 = om(10);
  37.     o2.display();
  38.     cout<<"\nImplisit 2 peramiter constructor called..\n";
  39.     om o3(20,30);
  40.     o3.display();
  41.     cout<<"\nExplisit 2  peramiter consructor called ..\n";
  42.     om o4 = om(20,30);
  43.     o4.display();
  44.     getch();
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement