好吧,請對我的代碼仔細檢查之下,它只是一個功能的一部分相較於C++中的空
void RepeatWord(){
system("cls");
string word = NULL;
string newword = NULL;
int repeats = 0;
while(true){
if(word == NULL){
cout<<"Currently no word is stored..";
cout<<"\n\nPlease enter a word: ";
cin>>word;
}
....
好,我一直在與其他編程語言,我總是在做一個比較一個NULL
的價值,但在C + + ......它似乎是一個不同的情況。錯誤說..
error: no match for 'operator==' in 'word == 0'
以及我在想,我只是比較一個NULL
,我真的不知道爲什麼這是錯的。比較一個值到NULL
到C++是不同的?請教我。由於
注:我知道的比Java
不要將'std :: string's設置爲null(此運行會引發異常)。 'std :: string word;'是一個空字符串。 – chris 2013-03-28 06:07:42
Woah woah ...你不能null這樣的對象。這不是Java。 – Mysticial 2013-03-28 06:07:51
@chris所以它真的不可能在C++中設置NULL值? – 2013-03-28 06:08:43