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

to find out the minimum of two integer number of two different classes using friend function

2075


How oops is better than procedural?

1026


How do you use inheritance in unity?

1024


What is polymorphism what are the different types of polymorphism?

947


What does oop mean in snapchat?

1153


What is encapsulation c#?

1013


What is the main purpose of inheritance law?

1147


What is the full form of oops?

1120


Hi friends I have experience of 6 months in website design and maintanence. Now i am looking for other IT jobs.. to switch platform. please post any interview you know in chennai.

2148


How many human genes are polymorphic?

1001


What is encapsulation selenium?

953


What is oops in simple words?

1032


Give two or more real cenario of virtual function and vertual object

2285


Why is polymorphism important in oop?

1010


Why is abstraction needed?

977