c++ - 错误 : &P cannot be used as a function

标签 c++ function

<分区>

我有这个代码:

#include<stdio.h>
#include<iostream>

double PVfut(int n, int r)
{
    double P[n];
    for(int m=0;m<n;m++){
        cout<<"Value:"<<endl;
        cin>>P[m];
        }

    double PV;
    double p;
    for(int m=0;m<n;m++){
        p*=(1+r);
        PV+=P(m)/(p);
    }
}
main(){
    cout<<PVfut(2,2)<<endl;
}

我在调用 PVfut 时遇到错误,指出 &P 不能用作函数

问题是什么?

最佳答案

您应该使用 P[m] 而不是 P(m)

关于c++ - 错误 : &P cannot be used as a function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33233029/

相关文章:

c - 用函数初始化c中动态分配的二维数组

objective-c - 比较 Objective-C 中的 block 和函数

C++ 复制构造函数采用错误的值

c++ - opencv中Mat的结构?

c++ - 将 lambda 传递给成员变量的构造函数

c - 使用函数的参数初始化静态变量

C++ 错误 2679 : binary'>>' : no operator found

c++ - GCC:对未使用的函数的奇怪未解决引用

json - Swift 从 JSON 请求生成通用函数

c++ - 返回数组但也接受函数作为参数的函数