比方說,我有以下幾點:通過字符數組來函數C++
char cipan[9];
那麼我應該傳遞給函數? get和set方法怎麼樣?
目前,我正在做這樣的
一套方法
void setCipan(char cipan[]){
this->cipan = cipan;
}
和get方法
char getCipan(){
return cipan;
}
和編譯時,我得到一個錯誤?
Im完全模糊..有人可以解釋我應該傳遞給函數嗎?
class userData{
private:
string name;
char dateCreate[9];
void userDataInput(string name,char dateCreate[]){
this->name = name;
this->dateCreate = dateCreate;
}
public:
//constructor
userData(string name){
userDataInput(name,dateCreate);
}
userData(string name,char dateCreate[]){
userDataInput(name,dateCreate);
}
//mutator methods
void changeName(string name){this->name = name;}
void changeDateCreate(char *dateCreate){this->dateCreate = dateCreate;}
//accesor methods
string getName(){return name;}
char *getDateCreate(){return dateCreate;}
};
正確粘貼完整的代碼。 – Sadique 2011-04-14 15:55:41
請參閱http://stackoverflow.com/questions/4810664/how-do-i-use-arrays-in-c – AProgrammer 2011-04-14 15:56:42
什麼是「功能」,什麼是「錯誤?」 – 2011-04-14 15:57:04