<函数> 不是 <类> 的成员

Swa*_*nav 6 c++ methods compiler-errors class turbo-c++

我已将我的函数“Credit”声明为带有一些参数的私有成员。我的观察是,每当我尝试在没有任何参数的情况下进行编译时,编译器都会成功编译。但是一旦我使用函数中的参数进行编译,编译器就会给出错误

“交易::信用”不是“交易”的成员

这是我的代码

class Transaction : public Menu
{
private :

    void Credit(int depost);//{ return 0;}

public :
    void Deposit();
    void Withdraw(){}
    void Transfer(){}
};

void Transaction :: Deposit()
{
       char custid[10]; int deposit;

       clrscr();
       cout << endl << endl << endl << endl << endl;
       cout << "\t\t\t\t  DEPOSIT " << endl;
       cout << "\t\t   Please enter your Customer ID" << endl;
       cin  >> custid;
       cout << "\t\t   Please enter the amount you want to deposit (in Rupees)" << endl;
       cin  >> deposit;

 //      Credit (depost);
}

void Transaction :: Credit (depost)
{

}
Run Code Online (Sandbox Code Playgroud)

我使用的是 Turbo C++,所以请根据这个 IDE 指导我。

Roc*_*Out 1

您缺少存款类型:

void Transaction :: Credit (int depost)
Run Code Online (Sandbox Code Playgroud)

  • 否决票是因为你在命名约定上强加了自己的观点,而这完全是主观的。删除最后一点,我将删除我的反对票。 (15认同)
  • 用大写字母命名函数并不是一个坏习惯。这只是一个意见。引用 Google 样式表[此处](https://google.github.io/styleguide/cppguide.html#Function_Names):“通常,函数应以大写字母开头,并且每个新单词都有一个大写字母” (9认同)