的成員我已經聲明瞭我的函數'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