Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // write a program to perform peramiterized constructor with single argument with implisit call and explisit call
- // write a program to perform peramiterized constructor with doubble argument with implisit call and explisit call
- #include<iostream.h>
- #include<conio.h>
- class om
- {
- int a,b;
- public:
- om(int x) // inside the class
- {
- a=x;
- b=0;
- } //single peramiter
- om(int x, int y); // doubble peramitersized constructor
- // out side the class.
- void display(); //out side class
- };
- om :: om (int x , int y)
- {
- a=x;
- b=y;
- }
- void om :: display()
- {
- cout<<"A ="<<a<<endl;
- cout<<"B ="<<b<<endl;
- }
- void main()
- {
- clrscr();
- cout<<"\nImplisit 1 peramiter constructor called..\n";
- om o(10);
- o.display();
- cout<<"\nExplisit 1 peramiter consructor called ..\n";
- om o2 = om(10);
- o2.display();
- cout<<"\nImplisit 2 peramiter constructor called..\n";
- om o3(20,30);
- o3.display();
- cout<<"\nExplisit 2 peramiter consructor called ..\n";
- om o4 = om(20,30);
- o4.display();
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement