银行账户程序的构建和启动问题
Bank Account Program Issues with build and getting started
转到另一个程序。这是一个模拟银行账户的程序。我需要你帮我显示余额、取款和存款。我怎样才能让这张表显示出存取款后的最终余额呢?
#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;
通过在它们后面加上括号,您试图调用name
和balance
类似的函数,但它们是string
s。去掉括号
您试图在这里调用name
和balance
作为函数:
cout << "balance for " << name () << " is " << balance() <<endl;
^^^^^^^ ^^^^^^^^^
但是name
是string
, balance
是double
。这个编辑将修复这个问题:
cout << "balance for " << name << " is " << balance <<endl;
相关文章:
- C++为构建时间获取QDateTime的可靠方法
- 无法在 CLion 中构建 C++ 项目
- 函数向量_指针有不同的原型,我可以构建一个吗
- 如何使用ndk-build.cmd构建Android.so文件
- 如何创建一个空的全局类并在启动时实例化它
- libssh 的函数在构建 libssh 时无法在 Qt 和 cmake 错误中找到
- 使用cmake从源代码构建MySQL连接器/C++失败(与以前的声明冲突)
- VSCode-有一个红色下划线,但程序构建和运行正确,并且出现配音错误
- 构建可组合有向图(扫描仪生成器的汤普森构造算法)
- 即使我读取了所有内容,在FIFO上打开的QSocketNotifier也会一直启动
- 无法使用Qt Creator在Windows中构建yaml-cpp
- Eclipse构建但不会启动精灵
- 我想在Android中将音频服务器(/frameworks/av/media/audioserver)构建为64位,但无法启动
- Buildbot:如何手动启动构建
- Eclipse SDL 构建错误:"启动配置中指定的程序不存在"
- 在带有代码块的64位窗口上使用libpqfe.h构建,无法正确启动
- 如何在构建器C++应用程序中使用JNI启动JVM
- 银行账户程序的构建和启动问题
- 如何在Visual Studio中构建之前启动应用程序
- 如何运行CMD脚本,而不是构建和启动c++控制台应用程序