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
What is interface? When and where is it used?
Can main method override?
They started with the brief introduction followed by few basic C++ questions on polumorphism, inheritance and then virtual functions. What is polymorphims? How you will access polymorphic functions in C? How virtual function mechanism works?
What are properties in oop?
Will I be able to get a picture in D drive to the c++ program? If so, help me out?
What is object-oriented programming? Webopedia definition
which feature are not hold visual basic of oop?
What is abstraction in oops?
What is coupling in oop?
Plese get me a perfect C++ program for railway/airway reservation with all details.
What do you mean by abstraction?
What type of loop is a for loop?
What does enum stand for?
What does and I oop mean in text?
if i have same function with same number of argument but defined in different files. Now i am adding these two files in a third file and calling this function . which will get called and wht decide the precedence?