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 |
how to swap to variables without using thrid variable in java?
What are different oops concepts?
What is object and class in oops?
Generally, in all C++ programs, texts are in white colour. Can we change the colour of the text(either input or output or both)? If so, help me out.
Write 7 differences between "Public" function and "Private" function?
What is polymorphism and types?
What is polymorphism and its types?
How can you overcome the diamond problem in inheritance?
WHAT IS THE ACTUAL DEFINATION OF OBJECT AND THE CLASS IN ONE SINGLE LINE WHICH THE INTERVIEWER WANT TO LISTEN.
WHEN A COPY CONSTER IS CALL ?
What does the keyword "static" mean?
What is extreme programming?