WHEN A COPY CONSTER IS CALL ?

Answer Posted / preeti

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 A //With copy constructor
{
private:
char *name;
public:
A()
{
name = new char[20];
}
~A()
{
delete name[];
}
//Copy constructor
A(const A &b)
{
name = new char[20];
strcpy(name, b.name);
}
};

Is This Answer Correct ?    9 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is encapsulation in oops?

534


What is abstraction in oop with example?

642


What is purpose of inheritance?

641


Which is not an object oriented programming language?

536


What is inheritance write a program to show use of inheritance?

611






What are properties in oop?

605


Where You Can Use Interface in your Project

1421


What is oops with example?

560


write a program to find 2 power of a 5digit number with out using big int and exponent ?

1891


what is the 3 types of system development life cycle

2429


can we make game by using c

3413


Please send ford technologies placement paper 2 my mail id

1652


What are different types of JVM's? for example we use dalvik jvm for android then what about the remaining operating systems?

1648


What is interface? When and where is it used?

1662


What is polymorphism programming?

599