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 will happen when the following code is run: int x; while(x<100) { cout<<x; x++; } 1) The computer will output "0123...99" 2) The computer will output "0123...100" 3) The output is undefined

7 Answers  


Can main method override?

0 Answers  


why we call c++ is object oriented lanaguage

7 Answers   HCL,


what is the technical or oop name of object?

1 Answers  


What is virtual function?where and when is it used?

2 Answers   Sitel,


what is object slicing

3 Answers   TCS,


Write on signed and unsigned integers and give three (3) examples each

1 Answers  


i am getting an of the type can not convert int to int *. to overcome this problem what we should do?

0 Answers  


What is oops and its features?

0 Answers  


What does enum stand for?

0 Answers  


what is the use of mutable key word

3 Answers   HCL,


How compiler selects(internally) required overridden function in inheritance?

2 Answers   CSC, Infinite Computer Solutions,


Categories