Wednesday, 30 January 2013

Parameterized Constructor


By on 02:26

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++):-

#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.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...