我有這個類:不能使功能常量
class BankAccount{
private:
char* ownerName;
char IBAN[14];
double balance;
}
而且我有這樣的功能:
char* BankAccount::getIban(){
return this->IBAN;
}
那一個是有效的,但我不知道爲什麼我不能定義getIban()像這樣的,因爲我想確保IBAN不能改變:
char* BankAccount::getIban()const{
return this->IBAN;
}
它說return value does not match the function type.
你應該使用'std :: string'作爲名字和IBAN –