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
to find out the minimum of two integer number of two different classes using friend function
What is constructor overloading in oop?
Get me an image implementation program.
How to handle exception in c++, For example in a functions i am assigning memory to some variables and also in next instructions in am dividing one variable also. If this functions generates a error while allocating memory to those variable and also while dividing the variable if i divide by zero then catch block how it will identify that this error has cone from perticular instruction
What is overloading and its types?
what is the drawback of classical methods in oops?
what's the basic's in dot net
Why do we use oop?
What is the point of polymorphism?
What language is oop?
What is the purpose of polymorphism?
What is a class and object?
What is polymorphism and types?
What is the difference between a constructor and a destructor?
What is the point of oop?