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 are the various types of stl containers?
Who created stl?
What do stl stand for?
In what scenario does the Logical file and Physical file being used?
write a program to convert a decimal number in to its equivalent binary number?
Can we use stl in coding interviews?
How stl is different from the c++ standard library?
What is stl stand for?
Explain stl.
What is meant by stl in c++?
draw a flowchart that accepts two numbers and checks if the first is divisible by the second.
What is the use of stl?
What does stl stand for in basketball?
What is a standard template library (stl)?
What is a stl vector?