c++个人银行账户管理3

本文档介绍了一个C++实现的个人银行账户管理系统,包括基类Account和两个派生类SavingsAccount、CreditAccount。系统由5个文件构成,分别是date.h、account.h、account.cpp、date.cpp和main.cpp,实现了账户的基本操作。
摘要由CSDN通过智能技术生成

c++个人银行账户管理3

C++个人银行账户管理2的基础再设计一个基类Account用来表述所有账户的共性,然后将SavingsAccount类变为其派生类,此外还要再派生出用来表示信用账户的类CreditAccount。
整个程序分为5个文件:date.h account.h是类定义头文件,date.cpp account.cpp是类实现文件,main.cpp是主函数文件。

main.cpp

#include<iostream>
#include<string.h>
#include"date.h"
#include"account.h"
using namespace std;
double Account::total = 0;
int main()
{
   
    Date d01(2008,11,5),d02(2008,12,5),d11(2008,11,25),d12(2008,12,20),d2(2009,1,1),dc1(2008,11,15),dc2(2008,12,1);
    cout<<"--------------------------------"<<"1001"<<"------------------------------"<<endl;
    SavingsAccount s0(2008,11,1,1001,0,0.015);
    s0.deposit(d01,5000);
    s0.deposit(d02,5500);
    s0.settle(d2);
    d2.show();
    s0.show();
    cout<<"------------------------------------------------------------------"<<endl;
    cout<<"--------------------------------"<<"1002"<<"------------------------------"<<endl;
    SavingsAccount s1(2008,11,1,1002,0,0.015);
    s1.deposit(d11,10000);
    s1.withdraw(d12,4000);
    s1.settle(d2);
    d2.show();
    s1.show();
    cout<<"------------------------------------------------------------------"<<endl;
    cout<<"--------------------------------"<<"1003"<<"------------------------------"<<endl;
    CreditAccount c0(2008,11,1,1003,0,10000,0.0005,50);
    c0.deposit(dc1,2000);
    c0.withdraw(dc2,2000);
    c0.withdraw(dc2,-c0.getDebt(dc2));      //结算利息
    c0.getDebt(d2);
    d2.show();
	c0.show();
	cout<<"-----------------------------"<<"各账户总金额"<<"-------------------------"<<endl;
    d2.show();
    c0.getTotal();
    cout<<"-------------------------------------------------------------------"<<endl;
}

account.h

#ifndef ACCOUNT_H_
#define 
  • 17
    点赞
  • 73
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值