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 coupling in oop?
What is abstract class in oop?
What is the benefit of oop?
Why do we use oops?
Can a varargs method be overloaded?
Why polymorphism is used in oops?
What does and I oop and sksksk mean?
Why oops is important?
What is polymorphism what is it for and how is it used?
What is object and class in oops?
What is the full form of oops?
What is constructor in oop?
What is the difference between abstraction and polymorphism?
How oops is better than procedural?
What is debug class?what is trace class? What differences are between them? With examples.