Answer Posted / 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 |
Post New Answer View All Answers
What do stl stand for?
How connect plc and pc through software
Define stl.
Why should a c++ programmer be interested in stl?
How do you convert stl to steps?
What does stl mean in slang?
What are the different types of stl containers?
write a program to convert a decimal number in to its equivalent binary number?
Is stl part of c++ standard?
How is stl different from c++ standard library?
Do you like to Submit Questions in Bulk under Same Category?? Then use our Bulk ListerDo you like to Submit Questions in Bulk under Same Category?? Then use our Bulk Lister
To modify an, existing worksheet. What steps are involved for: 1. Inserting and deleting rows and columns. 2. Printing cell formulas 3Jld displayed values 3. Using the page setup command
how to use C++?
How does an stl file work?
What is a standard template library (stl)? What are the various types of stl containers?