按照惯例,分了三个部分(头文件,头文件实现,main)来写。
只是按照他的要求粗略的写了一下,没有优化。
**仅供有需要的人以参考,如有错误请纠正我**
头文件:currency.h
#ifndef CURRENCY_H_
#define CURRENCY_H_
#include<iostream>
#include<exception>
enum signType { plu, minu };
class currency
{
private:
signType sign;
long amount;
public:
currency(signType theSign = plu, unsigned long theDollars = 0, unsigned int theCents = 0);
~currency() { }
void setValue(signType theSign, unsigned long Dollars, unsigned int Cents);
void setValue(double theAmount);
signType getSign() const;
unsigned long getDollars() const;
unsigned int getCents() const;
currency operator+(const currency & x) const;
friend std::ostream & operator<<(std::ostream & out, const currency &x);
void input();
void subtract(double x);
currency & percent(double x);
currency & multiply(