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
to find out the minimum of two integer number of two different classes using friend function
How oops is better than procedural?
How do you use inheritance in unity?
What is polymorphism what are the different types of polymorphism?
What does oop mean in snapchat?
What is encapsulation c#?
What is the main purpose of inheritance law?
What is the full form of oops?
Hi friends I have experience of 6 months in website design and maintanence. Now i am looking for other IT jobs.. to switch platform. please post any interview you know in chennai.
How many human genes are polymorphic?
What is encapsulation selenium?
What is oops in simple words?
Give two or more real cenario of virtual function and vertual object
Why is polymorphism important in oop?
Why is abstraction needed?