Write an operator overloading program to write S3+=S2.

Answers were Sorted based on User's Feedback



Write an operator overloading program to write S3+=S2...

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

Write an operator overloading program to write S3+=S2...

Answer / kkk

#include <iostream.h>
class ulhas
{


}

Is This Answer Correct ?    2 Yes 12 No

Post New Answer

More OOPS Interview Questions

what uses of c++ language?

3 Answers  


Does c++ support multilevel and multiple inheritance?

9 Answers   IBS, Wipro,


What is virtual destructor? Why?

3 Answers   Agile Software, College School Exams Tests, CSC,


what is costructor?

1 Answers  


What is encapsulation and abstraction? How are they implemented in C++?

0 Answers   Agilent, ZS Associates,






Can we create object of class with private constructor?

5 Answers  


write a program which best describes polymorphism in real world?

2 Answers   CTS, Infosys, NexGen,


what is multi level inheritance give n example ?

13 Answers   HDFC, Hulas Steel, Ness Technologies,


What is R T T I ?

6 Answers   Ness Technologies,


which is best institute to learn c,c++ in ameerpet hyderabad

1 Answers  


I have One image (means a group photo ) how to split the faces only from the image?............ please send the answer nagadurgaraju@gmail.com thanks in advace...

0 Answers  


is there any choice in opting subjects like 4 out of 7

0 Answers  


Categories