Write an operator overloading program to write S3+=S2.
Answer Posted / 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 |
Post New Answer View All Answers
Do you know about multiple inheritance?
What do you mean by variable?
What are the types of abstraction?
What is destructor oops?
What is protected in oop?
Why do we use inheritance?
What is encapsulation process?
Is this job good for future? can do this job post grduate student?
What is the difference between encapsulation and polymorphism?
Which is better struts or spring?
What is destructor give example?
What does and I oop mean?
Plese get me a perfect C++ program for railway/airway reservation with all details.
which feature are not hold visual basic of oop?
What do you mean by abstraction?