Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

tell about copy constructor

Answer Posted / sudha

A copy constructor is a special constructor in the C++
programming language used to create a new object as a copy
of an existing object.

There are 3 important places where a copy constructor is
called.

When an object is created from another object of the same
type
When an object is passed by value as a parameter to a
function
When an object is returned from a function


class B //With copy constructor
{
private:
char *name;
public:
B()
{
name = new char[20];
}
~B()
{
delete name[];
}
//Copy constructor
B(const B &b)
{
name = new char[20];
strcpy(name, b.name);
}
};




Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is it so that we can have virtual constructors but we cannot have virtual destructors?

4951


What is polymorphism what are the different types of polymorphism?

1014


What is overloading and its types?

1176


class type to basic type conversion

2414


How do you answer polymorphism?

1063


What type of loop is a for loop?

1091


What is the renewal class?

2763


Where You Can Use Interface in your Project

1893


Why is polymorphism used?

1042


What is object and class in oops?

1072


What is class in oop with example?

1103


Write a java applet that computes and displays the squares of values between 25 and 1 inclusive and displays them in a TextArea box

2621


INSTANCE FIELDS DECLARED private ARE ACCESSIBLE BY THE METHODS ONLY.CAN WE CHANGE THE private FIELD OF AN OBJECT IN A METHOD OF SOME OTHER OBJECT OF THE SAME CLASS?

2209


What are the components of marker interface?

1059


What is Difeerence between List obj=new ArrayList(); and ArrayList obj=new ArrayList()?

2541