Wednesday, October 19, 2011

Program:To illustrate constructor overloading in c++




Operator overloading
CODE:

#include<conio.h>
#include<iostream.h>
class abc
{
int a,b;
public:
abc()
{a=0;b=0;}
abc(int x)
{a=x;b=0;}
abc(int x,int y)
{a=x;b=y;}
void show()
{
 cout<<a<<"  "<<b<<endl;
}
};
void main()
{
clrscr();
abc obj1;
abc obj2(10);
abc obj3(10,20);
obj1.show();
obj2.show();
obj3.show();
getch();
}

Article by
Chief-Editor

He is a tech Enthusiast, an Altruist and calm mentor. He loves to code. He is also a creative graphic designer. Do check out his designfolio @ Jasmeet.asia If you like This post, you can follow me on Twitter.



For Further Reading,
C++ Program

1 comments:

Unknown on January 5, 2017 at 10:50 PM said...

Awesome. I am a beginner and this article helped me to resolve the problem .Thank

you author and the whole expect team.

http://www.wikitechy.com/view-

article/simple-constructor-overloading-program-in-cpp-with-example

Post a Comment