What is the Diffrence between a "assignment operator" and a
"copy constructor"?

Answers were Sorted based on User's Feedback



What is the Diffrence between a "assignment operator" and a "copy constructor"?..

Answer / kishore

Copy constructors are used during class object
initialization and assignment operators are invoked during
object assignment.

XYZ c;
XYZ Obj = c; -> invoke copy constructor
XYZ d;
d = c; -> invoke assignment operator

Is This Answer Correct ?    7 Yes 0 No

What is the Diffrence between a "assignment operator" and a "copy constructor"?..

Answer / bheda govind

Assignment operater are types,
(1)simple
(2)compond a+=5
(3)expresion a=a+b

Is This Answer Correct ?    1 Yes 0 No

What is the Diffrence between a "assignment operator" and a "copy constructor"?..

Answer / dee

assignment operator copies the values of one object to
another of the same class.It will excute only when the
right side of the variable is object and two sides are not
equal.It does shallow copy

Copy constructor craetes the object if its not existing and
copies the values of another object of the same class and
it does the deep copy.

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C++ General Interview Questions

What is fflush c++?

0 Answers  


How many namespaces are there in c++?

0 Answers  


Am studying basic c++ programming, have been given the following assignment. Design a linear program to calculate the maximum stress a material can withstand given a force and a diameter of a circle. To find the required area pi should be defined. Have most of the program sorted out but am at a loss as to how to show the calculations required. Can anyone help?

0 Answers  


List out function which we can call without using object

1 Answers  


How to create a reference variable in C++

1 Answers  






Write a program using shift_half( ) function to shift the elements of first half array to second half and vice versa.

0 Answers  


Is c++ the best programming language?

0 Answers  


What are structures and unions?

0 Answers  


What is a character in c++?

0 Answers  


Where do I find the current c or c++ standard documents?

0 Answers  


What are the differences between malloc() and calloc()?

0 Answers  


What is c++ course?

0 Answers  


Categories