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 the basic concept of inheritance?
What is abstract class in oop?
what is the sylabus for priliminaries?
what is the main difference between sizeof() operator in c and c++
What is polymorphism used for?
There are 2 empty jars of 5 and 3 liters capacity. And a river is flowing besides. I want to measure 4 liters of wanter using these 2 jars. How do you do this?
create a c++ program that will ask 10 numbers and display their sum using array.
What is meant by multiple inheritance?
What is the difference between and interface and an abstract class ?
4 Answers IBM, Infosys, Ness Technologies,
class type to basic type conversion
write a program which best describes polymorphism in real world?
2 Answers CTS, Infosys, NexGen,
A file pointer always contains the __________ of the file