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

how to find no of instances of an object in .NET?

1 Answers   Infosys,


What is virtual constructors/destructors?

4 Answers   IBS,


Do you know about multiple inheritance?

0 Answers   Motorola,


what is opps?why it is use in programming language?

2 Answers   Wipro,


Why do we need polymorphism in c#?

0 Answers  






Why do we need oop?

0 Answers  


What is protected in oop?

0 Answers  


Describe what an Interface is and how it?s different from a Class.

7 Answers   Spinsys,


What is operator overloading? Give Example

11 Answers   CTS, IBM, TCS,


IS IT NECESSARY TO INITIALIZE VARIABLE? WHAT IF THE INSTANCE VARIABLE IS DECLARED final ? IS IT NECESSARY TO INITIALIZE THE final VARIABLE AT THE TIME OF THEIR DECLARATION?

0 Answers  


what i oops concept, how many languages supports oops concept?

3 Answers   Value Labs,


What is design patterns in C++?

2 Answers   Persistent,


Categories