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
Why do pointers exist?
Prepare me a program for the animation of train
Explain virtual inheritance?
What is the purpose of polymorphism?
What is the point of oop?
What is object and class in oops?
What is polymorphism what is it for and how is it used?
What is encapsulation in oops?
What is encapsulation in simple terms?
What is methods in oop?
What are the data types in oop?
What is oops and why we use oops?
What is class encapsulation?
What is the advantage of oop over procedural language?
What is object in oops?