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 a scope resolution operator?
What are generic functions and generic classes?
How to execute business logic for only once ..?even though user clicks submit button multiple times by mistake..? (i disabled JavaScript)
what is object slicing
what is the difference between <stdio.h>and "stdio.h"?
What is a function in oop?
What is the oops and benefits of oops programming?
Why interface is used?
sir plz send me a set of questions that been frequently held in written examination during campus selection.
Name a typical usage of polymorphism
What do we mean by a hidden argument in C++?
what is the difference between function template and template of function?explain with example.