Parameterized Constructor:- Parametrised Constructor are the constructor that have more than one argument.It is used in c ++,java,c#(c sh...
Parameterized Constructor:-Parametrised Constructor are the constructor that have more than one argument.It is used in c ++,java,c#(c sharp) etc.
Example of Parametrised Constructor(in c++):-
Example of Parametrised Constructor(in c++):-
#include<iostream.h>
#include<conio.h>
class number
{
int x,y,z;
public:
number(int a,int b)
{
x=a;
y=b;
}
void sum()
{
z=x+y;
cout<<z;
}};
void main()
{
class no(20,30); //object
clrscr();
no.sum();
getch();
}
If you have any query then leave your comments and don't forgot to follow me on Google+,Facebook,Twitter.
COMMENTS