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
What does sksksk mean in text slang?
What is encapsulation in simple terms?
How to improve object oriented design skills?
What is the difference between procedural programming and oops?
They started with the brief introduction followed by few basic C++ questions on polumorphism, inheritance and then virtual functions. What is polymorphims? How you will access polymorphic functions in C? How virtual function mechanism works?
write a program using c++ to implement single contiguous memory mangement techniques.display the content of the main memory after yhe allocation of jobs and percentage of the wastage of the main memory
What is Difeerence between List obj=new ArrayList(); and ArrayList obj=new ArrayList()?
Can abstract class have normal methods?
What are the important components of cohesion?
What is polymorphism explain its types?
Write a program to sort the number with different sorts in one program ??
Why is static class not inherited?
How to hide the base class functionality in Inheritance?
What is polymorphism explain?
What are two types of polymorphism?