When copy constructor can be used?

Answers were Sorted based on User's Feedback



When copy constructor can be used?..

Answer / jack

while compiler encounters following situation it uses the CC
1.when assigning one object to another object of same class
type

2.When an object is passed to the called function.....

3.when a function returns the object type and assigns it to
the another object..........

Is This Answer Correct ?    18 Yes 4 No

When copy constructor can be used?..

Answer / sachin magdum

1. "assigning" - don't use this word, it should be
initializing an object using another object of same type
2. When the object is passed to function - "by value"
3. when a function returns the object type - "by value"
here doesn't matter if you are assigning that returned
value to to another object or not.

Is This Answer Correct ?    9 Yes 4 No

When copy constructor can be used?..

Answer / vikas sood

hi fellows..try this code
class A {
public:
A() { }
A(const A& rhs)
{
cout<<"inside copy constructor..";
}
};

int main()
{
std::vector<A> aVec(10);
}

The answer to this is another reason a copy constructor
will be called.

Is This Answer Correct ?    2 Yes 1 No

When copy constructor can be used?..

Answer / priya

Whenever u want to copy the members of one object to another
object of the same class in a C++ program.

Is This Answer Correct ?    3 Yes 3 No

Post New Answer

More C++ General Interview Questions

How do you save a c++ program?

0 Answers  


What is implicit pointer in c++?

0 Answers  


What is the main purpose of overloading operators?

0 Answers  


What is the use of ‘using’ declaration?

1 Answers  


How const int *ourpointer differs from int const *ourpointer?

0 Answers  






When do we use copy constructors?

0 Answers  


What is the difference between reference and pointer?

0 Answers  


How can you quickly find the number of elements stored in a a) static array b) dynamic array ? Why is it difficult to store linked list in an array?how can you find the nodes with repetetive data in a linked list?

0 Answers  


What is ios :: in in c++?

0 Answers  


Which bit wise operator is suitable for turning off a particular bit in a number?

0 Answers  


There is a magic square matrix in such a way that sum of a column or a row are same like 3 5 2 4 3 3 3 2 5 sum of each column and row is 10. you have to check that matrix is magic matrix or not?

1 Answers   TCS,


What is the role of static keyword for a class member variable?

0 Answers  


Categories