您的位置:首页 > 编程语言 > C语言/C++

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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: