Why a "operator=(...)" when there is a copy ctor?
Answers were Sorted based on User's Feedback
Answer / guest
You use the assignment operator (operator = ()) whenever an
existing object is to be replaced with a different object.
The copy constructor X(const X&) is used to create a new
instance of an X-object exactly like another.
Notice the subtle difference. Assignment changes an existing
object while construction creates a new object. You can view
assignment as the application of a destructor, to flush away
the existing object, followed by a copy construction, to
make an exact copy of the assigned object.
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / arun
Copy Constructor means creation of new object and after that
copy properties of some exiting object to newly created object.
Overloading assignment operator is that copy properties of
some exiting object to another exiting object of same type.
| Is This Answer Correct ? | 1 Yes | 0 No |
What do you mean by public, private, protected and friendly?
What is the difference between pass by value,pass by pointer,pass by reference in the catch block in the exception handling in c++
What does <> mean pseudocode?
Base class has two public data members. How can i derive a new class with one datamember as public and another data member as private?.
What are the data types in oop?
What is abstraction?
Have you ever interfaced with a database?
What is friend function?
what type of questions
Program to read a comment string
what is Class in oops with example?
why c++ is called OOPS? waht is inherutance? what is compiler?