银行账户程序的构建和启动问题

Bank Account Program Issues with build and getting started

本文关键字:构建 启动 问题 程序      更新时间:2023-10-16

转到另一个程序。这是一个模拟银行账户的程序。我需要你帮我显示余额、取款和存款。我怎样才能让这张表显示出存取款后的最终余额呢?

#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;
    }
cout << "balance for " << name () << " is " << balance()
    <<endl;

通过在它们后面加上括号,您试图调用namebalance类似的函数,但它们是string s。去掉括号

更重要的是,是什么让你认为必须在中包含括号?c++中可能有一些基本的部分让你感到困惑(函数),你应该努力去完全理解。

您试图在这里调用namebalance作为函数:

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

但是namestring, balancedouble。这个编辑将修复这个问题:

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