fsdfsdfs
By: a guest | Mar 22nd, 2010 | Syntax:
None | Size: 1.91 KB | Hits: 74 | Expires: Never
#ifndef MONEY_H
#define MONEY_H
//money.h
//Program to demonstrate the class Money.
#include <iostream>
#include <cstdlib>
#include <cctype>
using namespace std;
//Class for amounts of money in euros.
class Money
{
public:
friend Money add(Money amount1, Money amount2);
//Precondition: amount1 and amount2 have been given values.
//Returns the sum of the values of amount1 and amount2.
friend bool equal(Money amount1, Money amount2);
//Precondition: amount1 and amount2 have been given values.
//Returns true if the amount1 and amount2 have the same value;
//otherwise, returns false.
Money(long euros, int cents);
//Initializes the object so its value represents an amount with the
//euros and cents given by the arguments. If the amount is negative,
//then both euros and cents must be negative.
Money(long euros);
//Initializes the object so its value represents €euros.00.
Money();
//Initializes the object so its value represents €0.00.
double getValue();
//Precondition: The calling object has been given a value.
//Returns the amount of money recorded in the data of the calling object.
void input(istream& ins);
//Precondition: If ins is a file input stream, then ins has already been
//connected to a file. An amount of money, including a euro sign, has been
//entered in the input stream ins. Notation for negative amounts is -€100.00.
//Postcondition: The value of the calling object has been set to
//the amount of money read from the input stream ins.
void output(ostream& outs);
//Precondition: If outs is a file output stream, then outs has already been
//connected to a file.
//Postcondition: A euro sign and the amount of money recorded
//in the calling object have been sent to the output stream outs.
private:
long cents;
};
#endif // MONEY_H