gpt4 book ai didi

c++ - 错误 : cannot convert 'double' to 'double(double, double, double)' in assignment

转载 作者:太空宇宙 更新时间:2023-11-03 10:45:51 96 4
gpt4 key购买 nike

我知道我的作业很草率,这是我在这门课上的第 4 次作业。任何帮助将不胜感激,谢谢。

double  getPrincipal(0);
double getRate(0);
double getYears(0);
double computeAmount(double getPrincipal, double getRate, double getYears);
double displayAmount(double principal, double rate, double years, double amount);

cout << "what is the principal ammount?" << endl;
cin >> getPrincipal;

cout << "What is the percentage rate?" << endl;
cin >> getRate;

cout << "Over how many years will the money stay in the bank?" << endl;
cin >> getYears;

computeAmount = pow((1 + getRate / 100),getYears); // This is where i got the error

最佳答案

您试图通过为函数赋值来搞乱带有变量函数

double  computeAmount(double getPrincipal, double getRate, double getYears);

通过这一行,您将 computeAmount() 声明为一个以 3 个 double 作为参数并返回一个 double 的函数。

但是,在这一行中,

computeAmount = pow((1 + getRate / 100),getYears);

您正在尝试将其用作变量。

取决于您的目的,您可能想要更改这两行之一。例如,您可以删除第一行,并将第二行更改为:

double computeAmount = pow((1 + getRate / 100),getYears);

关于c++ - 错误 : cannot convert 'double' to 'double(double, double, double)' in assignment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22077348/

96 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com