银行账户计划有关构建和入门的问题

时间:2013-05-22 02:14:45

标签: c++ visual-studio-2010 compiler-errors

到另一个程序。这是一个模拟银行账户的程序。我需要帮助显示余额,提款和存款。如何在取款/存款后显示最终余额?

#include <iostream>
#include <string>
#include "BACCOUNT.H"

    using namespace std;
    int main ()
    {
        double amount = 0.0;
        double withrdraw = 0.0;
        double deposit = 0.0;
        string name;
        double startamount = 100.00;
        double balance = 0.0;


        cout << "name: ";
        cin >> name;

        cout << "initial balance: " << startamount <<endl;


        cout << "deposit? ";
        cin >> amount;
        cout << "withdraw? ";
        cin >> amount;


        cout << "balance for " << name  << " is " << balance << endl;

        system ("pause");

        return 0;
    }

2 个答案:

答案 0 :(得分:3)

cout << "balance for " << name () << " is " << balance()
    <<endl;

通过在它们后面添加括号,您尝试调用namebalance类似函数,但它们是string。删除括号。

更重要的是,是什么让你认为必须在那里包括括号?可能有一个C ++的基本部分,你应该寻求完全理解(功能)。

答案 1 :(得分:1)

您尝试在此处调用namebalance作为函数:

cout << "balance for " << name () << " is " << balance() <<endl;
                          ^^^^^^^              ^^^^^^^^^

namestringbalancedouble。此编辑将解决问题:

cout << "balance for " << name << " is " << balance <<endl;