netx_iit

How to create parameterize constructor using c++

Jun 27th, 2020 (edited)
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. /* parameterized cons.....*/
  2. #include<stdio.h>
  3. #include<conio.h>
  4. #include<iostream.h>
  5. class xyz
  6. {
  7.     public:
  8.     xyz()//default cons
  9.     {
  10.         cout<<"\nI am default cons..";
  11.     }
  12.  
  13.     xyz(int x,int y)
  14.     {
  15.         cout<<"\nI am parameterized cons...";
  16.         cout<<"\nValue of x is "<<x<<" and y is "<<y;
  17.     }
  18. };
  19. int main()
  20. {
  21.     clrscr();
  22.     xyz x1,x2(10,20);
  23.     getch();
  24.     return 0;
  25. }
Add Comment
Please, Sign In to add comment