realaccount.cpp

来自「financal instrument pricing using c」· C++ 代码 · 共 55 行

CPP
55
字号
// RealAccount.cpp
//
// (C) Datasim Education BV  2002

#include "RealAccount.hpp"

// Constructors and destructor
RealAccount::RealAccount(): Account()
{ // Default constructor

	bal=0.0;
}

RealAccount::RealAccount(double balance): Account()
{ // Constructor with initial balance

	bal=balance;
}

RealAccount::RealAccount(const RealAccount& source): Account(source)
{ // Copy constructor

	bal=source.bal;
}

RealAccount:: ~RealAccount()
{ // Destructor
}

// Virtual functions to be define in derived classes
void RealAccount::Withdraw(double amount)
{ // Withdraw some money

	if (amount>bal) throw NoFundsException();
	else bal-=amount;
}

double RealAccount::GetBalance()
{ // Return the balance

	return bal;
}

// Operator overloading
RealAccount& RealAccount::operator = (const RealAccount& source)
{ // Assignment operator

	// Call base class assignment
	Account::operator = (source);

	bal=source.bal;
	return *this;
}

⌨️ 快捷键说明

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