You are here:

C++/about constructor overloading

Advertisement


Question
what is constructor overloading? give example

Answer
Hi Naim

Creating Constructor of various form is called constructor overloading

class X
{
private:
int x, y;
public:
X()//default
{
x=0; y=0;
}

X(int a,int b)//overloaded constructor
{
x=a; y=b;
}
};

void main()
{
X a;// this invokes the default constructor
X b(3,2); // you can create obj like this to invoke the second constructor
}

See this prog to know it better
http://www.scodz.com/ViewProgram.php?uid=4&link=373

if you still have any doubt please feel free to get back to me.

regards
Joydeep Bhattacharya
http://www.scodz.com

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Joydeep Bhattacharya

Expertise

TSR, Socket and Very Complex Mathematical Problem

Experience

Worked on many OOP projects with design patterns

Organizations
http://www.scodz.com

Publications
http://www.scodz.com

Education/Credentials
Master of Computer Applications

Awards and Honors
Being a proud owner of a website of programming called http://www.scodz.com

Past/Present Clients
http://www.funforu.com http://www.dhoondho.com http://analysingc.50webs.com

©2016 About.com. All rights reserved.