account.h

来自「C++Primer中文版 第三版 深入系列 Primer 第三版 著 中」· C头文件 代码 · 共 51 行

H
51
字号
#ifndef ACCOUNT_H
#define ACCOUNT_H

#include <string>
using std::string;

class Account {
public:
        Account( double amount, const string &owner );

        string owner();
	double dailyReturn();
        static void raiseInterest( double );
        static double interest();

	friend int compareRevenue( Account& , Account* );
private:
        static double  _interestRate;
        double         _amount;
        string         _owner;

	static const int nameSize = 16;
        static const char name[nameSize];
};


inline Account::Account( double amount, const string &owner ) :
  _amount( amount ),
  _owner( owner )
  { /* all the work is done with the member initialization list */ }


inline string Account::owner()
  { return _owner; }

inline double Account::dailyReturn()
  {
    return( _interestRate / 365 * _amount );
  }

inline void Account::raiseInterest( double incr )
  {
    _interestRate += incr;
  }

inline double Account::interest()
  { return _interestRate; }


#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?