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
What is encapsulation in oops?
What is abstraction in oop with example?
What is purpose of inheritance?
Which is not an object oriented programming language?
What is inheritance write a program to show use of inheritance?
What are properties in oop?
Where You Can Use Interface in your Project
What is oops with example?
write a program to find 2 power of a 5digit number with out using big int and exponent ?
what is the 3 types of system development life cycle
can we make game by using c
Please send ford technologies placement paper 2 my mail id
What are different types of JVM's? for example we use dalvik jvm for android then what about the remaining operating systems?
What is interface? When and where is it used?
What is polymorphism programming?