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 |
What is abstraction example?
write a program to find 2^n+1 ?
Write on signed and unsigned integers and give three (3) examples each
Should you protect the global data in threads? Why or why not?
why to use template classes in c++?
What is the types of inheritance?
What is polymorphism and its types?
which is best institute to learn c,c++ in ameerpet hyderabad
What does I oop mean?
Why do while loop is used?
What is encapsulation in simple terms?
Can an interface inherit a class?