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...


how to overload << and >> operator in c++

Answers were Sorted based on User's Feedback



how to overload << and >> operator in c++..

Answer / manav sharma

class chocoBox {
private:
int pieCount;
float boxPrice;

public:
// By giving default arguments, const acts like
// 0, 1 and 2 argument contructor
myClass(int pCount = 10, float bPrice = 20.0)
: pieCount(pCount), boxPrice(bPrice)
{ }

int getPieCount() { return pieCount; }
float getBoxPrice() { return boxPrice; }
void setPieCount(int pc) { pieCount = pc; }
void setBoxPrice(float bp) {boxPrice = bp; }
};

/* Lets overload the operator << of ostream class. We will
return a reference of ostream class for cascading calls
e.g. cout<<obj1<<obj2
*/
ostream& operator<< (ostream &stream, const myClass &obj)
{
stream<<obj.GetPieCount<<" "<<obj.GetBoxPrice<<endl;
return (stream);
}

Is This Answer Correct ?    5 Yes 0 No

how to overload << and >> operator in c++..

Answer / abed

in c++ << and >> overloaded as the insertion and out put
symbole

Is This Answer Correct ?    2 Yes 1 No

how to overload << and >> operator in c++..

Answer / ramya

"<<" this inserssion perrator is used for output the
messages&values
">>"this exsersition operator is used for input the values
sentax:

return_type operator op(arguments_list)
{
----
----
}

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More STL Interview Questions

What is stl in oop?

0 Answers  


What is meant by stl in c++?

0 Answers  


What is a standard template library (stl)? What are the various types of stl containers?

0 Answers  


What is stl stand for?

0 Answers  


What two types of containers does the stl provide?

0 Answers  


how to get the sum of two integers?

2 Answers  


Define the terms: field, record, table and database

5 Answers  


What is Template Specialization?

1 Answers   Lucent,


What does stl mean in slang?

0 Answers  


What are the symptoms of stl?

0 Answers  


What is the use of stl?

0 Answers  


What is the name of your birth place?

0 Answers  


Categories