C++ 指针帮助缺少参数列表用户帐户::getBalance

标签 c++ arrays pointers

我目前正在一个银行系统上工作以完成一项任务,我有一个拥有一系列账户的客户,我试图输出数组中每个账户的金额。它说我需要使用我认为但不确定我会做什么的指针。 :s

double customer:: getAccounts()
{
    for (int i=0;i<5;i++)
    {
        if(Accounts[i].getBalance != 0)
        {
        double x = Accounts[i].getBalance;
        return x;
        }
    }       
}

double customer :: specAccount(int num)
{
    double x = Accounts[num].getBalance;
    return x;
}

错误 C3867:“Account::getBalance”:函数调用缺少参数列表;使用 '&Account::getBalance' 创建指向成员的指针

最佳答案

假设 getBalance 是一个方法:

double x = Accounts[num].getBalance();

或者如果 Accounts 是一个指针数组:

double x = Accounts[num]->getBalance();

关于C++ 指针帮助缺少参数列表用户帐户::getBalance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20253512/

相关文章:

c++ - BeagleBone Black 从用户空间获取中断

arrays - 快速传递具有不同内容的数组

arrays - 强制 TypeScript 数组包含给定值的元素

c - 如何为传递给函数的指针分配内存?

c - 冒泡排序指针数组

从 Int 数组地址创建一个 Int 数组

带有运算符的 std::array 的 C++11 类型别名

c++ - Getline 由于某种原因不起作用

c++ - 在 R 和 Rcpp 中找到最大的 n 个唯一值及其频率

c - 通过多个函数访问数组