Wednesday, 30 January 2013

Default Constructor


By on 02:21

Default Constructor:-Default Constructor are the constructor that accept no parameter or 0 parameter.Default constructor is used in c ++,java,c#(c sharp) etc.

Example of Default Constructors(in c++):-

#include<iostream.h>
#include<conio.h>
class swap
{
int x,y;
public:
swap()          //default constructor
{
x=10;
y=20;
}
void swap()
{
x=x+y;
y=x-y;
x=x-y;
cout<<x<<y;
}};
void main()
{
class sw;        //object
clrscr();
sw.swap();
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...