C++ <function> 不是 <class> 的成员
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25693849/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
<function> is not a member of <class>
提问by Swanav
I have declared my function 'Credit' as a private member with some arguments. My observation is that whenever I try to compile without any argument the compiler will compile successfully. but as soon as I compile with the arguments in the function, the compiler gives an error
我已将我的函数 'Credit' 声明为带有一些参数的私有成员。我的观察是,每当我尝试在没有任何参数的情况下进行编译时,编译器都会成功编译。但是一旦我用函数中的参数进行编译,编译器就会给出一个错误
'Transaction :: Credit' is not a member of 'Transaction'
“交易::信用”不是“交易”的成员
Here is my code
这是我的代码
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)
{
}
I am using Turbo C++, so please guide me according this IDE.
我正在使用 Turbo C++,所以请根据这个 IDE 指导我。
采纳答案by RockOnRockOut
You're missing the type of depost:
你错过了depost的类型:
void Transaction :: Credit (int depost)
And it is considered bad practice to start the name of functions with a capital letter. The names of classes should start with capital letters. Functions and variables should have names that start with lowercase letters.
以大写字母开头的函数名称被认为是不好的做法。类的名称应以大写字母开头。函数和变量的名称应该以小写字母开头。