的成员我已经声明了我的函数'Credit'作为一个私有成员的一些参数。我的观察是,只要我尝试编译没有任何参数,编译器就会成功编译。但只要我编译的函数的参数,编译器会给出错误<function>不是<class>
“交易信用::”不是“交易”
这里的一员是我的代码
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)
{
}
我正在使用Turbo C++,因此请根据此IDE指导我。
定义'void Transaction :: Credit(depost)'应该有'depost'的类型说明符,即 'void Transaction :: Credit(int depost)' – YoungJohn 2014-09-05 20:58:19
就是这样!谢谢。但为什么我们需要一个类型说明符? @YoungJohn – Swanav 2014-09-05 21:01:50
@Swanav:你为什么不呢? C++是一个强大的(无论如何...),静态类型的语言。 – 2014-09-05 21:04:33