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
Is stl part of c++ standard?
Describe the My Computer and My Documents folders; identify the elements that are present in every Window.
If P is the population on the first day of the year, B is the birth rate, and D is the death rate, the estimated population at the end of the year is given by the formula: The population growth rate is given by the formula: B – D Write a program that prompts the user to enter the starting population, birth and death rates, and n, the number of years. The program should then calculate and print the estimated population after n years. Your program must have at least the following functions: 1. growthRate: This function takes its parameters the birth and death rates, and it returns the population growth rate. 2. estimatedPopulation: This function takes its parameters the current population, population growth rate, and n, the number of years. It returns the estimated population after n years Your program should not accept a negative birth rate, negative death rate, or a population less than 2. please answer my question ....
totoo po ba ang manga aliens!
What are the different types of stl containers?
what is template and type convertion
What are the symptoms of stl?
How does an stl file work?
how to use C++?
write a program to convert a decimal number in to its equivalent binary number?
When did c++ add stl?
What are the components of stl?
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.
What is a list in c++ stl?
What is stl in c++ with example?