f1213.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:
C#编程
开发平台:
Visual C++
- //=====================================
- // f1213.cpp
- // Type Conversions
- //=====================================
- #include<iostream>
- using namespace std;
- #include"savings_bro.h"
- #include"checking_bro.h"
- #include"accountlist.h"
- //-------------------------------------
- int main(){
- Savings s1("3277",3000), s2("3279", 5000);
- Checking c1("888"), c2("398", 10000);
- AccountList a;
- a.add(s1); a.add(s2);
- a.add(c1); a.add(c2);
- Account* p;
- if(p = a.find("3277")) p->deposit(100);
- if(p = a.find("888")) p->deposit(2000);
- if(p = a.find("3279")) p->withdrawal(2500);
- if(p = a.find("398")) p->withdrawal(1555.5);
- Checking* pC;
- Savings* pS;
- for(Node* p=a.getFirst(); p; p=p->next)
- if(pC = dynamic_cast<Checking*>(&(p->acnt)))
- pC->deposit(pC->Account::getBalan()*0.05);
- else if(pS = dynamic_cast<Savings*>(&(p->acnt)))
- pS->deposit(pS->Account::getBalan()*0.1);
- a.display();
- }//====================================