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 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
Can main method override?
why we call c++ is object oriented lanaguage
what is the technical or oop name of object?
What is virtual function?where and when is it used?
what is object slicing
Write on signed and unsigned integers and give three (3) examples each
i am getting an of the type can not convert int to int *. to overcome this problem what we should do?
What is oops and its features?
What does enum stand for?
what is the use of mutable key word
How compiler selects(internally) required overridden function in inheritance?
2 Answers CSC, Infinite Computer Solutions,