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 |
I hv a same function name,arguments in both base class and dervied class, but the return type is different. Can we call this as a function overloading? Explain?
Name a typical usage of polymorphism
How can we use the preprocessor #if and #elseif.
What is abstraction?
What is pointer in oop?
What type of Job you are providing?
Difference between realloc() and free?
what are the disadvantages of C++?
25 Answers ATS, Infosys, UNI, Wipro,
Question: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date.
What are the 3 pillars of oop?
What is Difeerence between List obj=new ArrayList(); and ArrayList obj=new ArrayList()?
Why we use classes in oop?