Share Pastebin
Guest
Public paste!

fsdfsdfs

By: a guest | Mar 22nd, 2010 | Syntax: None | Size: 1.91 KB | Hits: 74 | Expires: Never
Copy text to clipboard
  1. #ifndef MONEY_H
  2. #define MONEY_H
  3.  
  4. //money.h
  5. //Program to demonstrate the class Money.
  6. #include <iostream>
  7. #include <cstdlib>
  8. #include <cctype>
  9. using namespace std;
  10.  
  11. //Class for amounts of money in euros.
  12. class Money
  13. {
  14. public:
  15.     friend Money add(Money amount1, Money amount2);
  16.     //Precondition: amount1 and amount2 have been given values.
  17.     //Returns the sum of the values of amount1 and amount2.
  18.  
  19.     friend bool equal(Money amount1, Money amount2);
  20.     //Precondition: amount1 and amount2 have been given values.
  21.     //Returns true if the amount1 and amount2 have the same value;
  22.     //otherwise, returns false.
  23.  
  24.     Money(long euros, int cents);
  25.     //Initializes the object so its value represents an amount with the
  26.     //euros and cents given by the arguments. If the amount is negative,
  27.     //then both euros and cents must be negative.
  28.     Money(long euros);
  29.     //Initializes the object so its value represents €euros.00.
  30.  
  31.     Money();
  32.     //Initializes the object so its value represents €0.00.
  33.  
  34.     double getValue();
  35.     //Precondition: The calling object has been given a value.
  36.     //Returns the amount of money recorded in the data of the calling object.
  37.  
  38.     void input(istream& ins);
  39.     //Precondition: If ins is a file input stream, then ins has already been
  40.     //connected to a file. An amount of money, including a euro sign, has been
  41.     //entered in the input stream ins. Notation for negative amounts is -€100.00.
  42.     //Postcondition: The value of the calling object has been set to
  43.     //the amount of money read from the input stream ins.
  44.  
  45.     void output(ostream& outs);
  46.     //Precondition: If outs is a file output stream, then outs has already been
  47.     //connected to a file.
  48.     //Postcondition: A euro sign and the amount of money recorded
  49.     //in the calling object have been sent to the output stream outs.
  50. private:
  51.     long cents;
  52.  
  53. };
  54.  
  55. #endif // MONEY_H