Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Why do pointers exist?

1097


Prepare me a program for the animation of train

2477


Explain virtual inheritance?

1204


What is the purpose of polymorphism?

1126


What is the point of oop?

1192


What is object and class in oops?

1072


What is polymorphism what is it for and how is it used?

1022


What is encapsulation in oops?

1014


What is encapsulation in simple terms?

1041


What is methods in oop?

981


What are the data types in oop?

1103


What is oops and why we use oops?

1049


What is class encapsulation?

1096


What is the advantage of oop over procedural language?

1090


What is object in oops?

1067