Write an operator overloading program to write S3+=S2.
Answer Posted / 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 |
Post New Answer View All Answers
How do you define social class?
what is the sylabus for priliminaries?
What is oops concept with example?
Write a program to sort the number with different sorts in one program ??
What is polymorphism explain its types?
Why is static class not inherited?
Please send ford technologies placement paper 2 my mail id
What is interface in oop?
What is encapsulation with real life example?
officer say me - i am offered to a smoking , then what can you say
What is multilevel inheritance?
What is object and class in oops?
write string class as your own class in java without using any built-in function
program for insertion ,deletion,sorting in double link list
Why do we need polymorphism in c#?