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 |
i got a backdoor offer in process global,Bangalore..Can i work with it?
What is Agile methodology?
20 Answers ABC, Accenture, College School Exams Tests, Inmar, Microsoft, Sapient,
What is property in oops?
What is the difference between abstraction and polymorphism?
what is the difference between class and structure in C++?
what is function overloading..?
WHAT IS THE ACTUAL DEFINATION OF OBJECT AND THE CLASS IN ONE SINGLE LINE WHICH THE INTERVIEWER WANT TO LISTEN.
what is difference between String s=new String("vali"); String s="vali"
tel me oops defination in single line
How to execute business logic for only once ..?even though user clicks submit button multiple times by mistake..? (i disabled JavaScript)
how to find the correct email address format by using the programe?
How can you overcome the diamond problem in inheritance?