c++:构造与析构函数基本,银行类
2016-06-06 22:33
357 查看
#include <iostream>
using namespace std;
class bank
{
public:
bank();
~bank()
{
cout<<"show the money"<<endl;
}
void moneybase(double base);
void moneyput(double put);
void moneyget(double get);
private:
double money;
};
bank::bank()
{
cout<<"input the money"<<endl;
}
void bank::moneybase(double base)
{
money=base;
}
void bank::moneyput(double put)
{
double p;
cin>>put;
p=money-put;
cout<<p<<endl;
}
void bank::moneyget(double get)
{
double g;
cin>>get;
g=money+get;
cout<<g<<endl;
}
int main ()
{
bank B;
B.moneybase(10000);
B.moneyget(1);
B.moneyput(1);
return 0;
}
using namespace std;
class bank
{
public:
bank();
~bank()
{
cout<<"show the money"<<endl;
}
void moneybase(double base);
void moneyput(double put);
void moneyget(double get);
private:
double money;
};
bank::bank()
{
cout<<"input the money"<<endl;
}
void bank::moneybase(double base)
{
money=base;
}
void bank::moneyput(double put)
{
double p;
cin>>put;
p=money-put;
cout<<p<<endl;
}
void bank::moneyget(double get)
{
double g;
cin>>get;
g=money+get;
cout<<g<<endl;
}
int main ()
{
bank B;
B.moneybase(10000);
B.moneyget(1);
B.moneyput(1);
return 0;
}
相关文章推荐
- C++中STL常用算法概要
- c++作业七
- C++ 笔记1: 字符串操作1
- C++中类的6个默认成员函数
- C++走向远洋——64(项目三、数组类模板)
- Microsoft Speech Platform SDK,语音识别
- C++回顾(2)——引用
- C++primer第15章习题解答
- 深入理解C++的多态性
- C++连接MYSQL数据库
- C++的标准命名空间使用
- 跟我一起学C++之从C到C++(结构体内存对齐)
- 稍微深入点理解C++复制控制【转】
- 跟我一起学C++之从C到C++(const与#define)
- C++内存动态分配和引用
- C的读书笔记 --c语言概述
- 【天梯赛-初赛题】L2-004 关于堆的判断
- C++之*与->的重载
- Poco c++学习资料
- Will Go eventually replace C++ as Google hoped when Go came out?