Write an operator overloading program to write S3+=S2.
Answers were Sorted based on User's Feedback
Answer / som shekhar
class A
{
int id;
public:
A& operator +(const A& a1)
{
A a;
a.id = id + a1.id;
return a;
}
A & operator =(const A& a1)
{
if( this == &a1)
return;
else
{
A a;
a.id = a1.id;
return a;
}
}
};
S3 += S2 internaly will be called as
S3->operator=(s3->operator+(s2));
In this case first + operator will be called and then
assignment operator will be called.
| Is This Answer Correct ? | 0 Yes | 1 No |
Why do we use inheritance?
what is the advantage in software? what is the difference between the software developer and Engineer
Round up a Decimal number in c++.. example Note = 3.5 is as 4 3.3 is as 3
3 Answers Accenture, Cognizant, IBM,
what type of questions
What is overriding in oops?
What are callback functions in c++
Write pseudo code for push in a stack?
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 5 oop principles?
What is multiple inheritance?
Finding of the 4 larger (bigger) numbers from the list like{1245,4587,2145,1163,29987,65783.....}
What is a superclass in oop?