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
#include
What is polymorphism in oop example?
Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.
What is pure oop?
Whats is abstraction in oops?
What is debug class?what is trace class? What differences are between them? With examples.
What are the 4 main oop principles?
What is the full form of oops?
What is the highest level of cohesion?
Why is there no multiple inheritance?
What is encapsulation example?
What is multilevel inheritance in oop?
Why do while loop is used?
Write a java applet that computes and displays the squares of values between 25 and 1 inclusive and displays them in a TextArea box
if i have same function with same number of argument but defined in different files. Now i am adding these two files in a third file and calling this function . which will get called and wht decide the precedence?