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 polymorphism used for?
What is the difference between C++ and java?
What is difference between pop and oop?
what is costructor?
if u write a class do u write Assignment operator and copy constructor
define oops concept with example
What is a linked list?
What is static in oop?
What is coupling in oops?
What is the renewal class?
What is function overloading?,describe it with the example.
What are the three parts of a simple empty class?