bool yes()
을 호출하려고 시도 중 int main
입니다. 위에 표시된 오류가 계속 발생합니다. 함수 호출 안에 char c
을 포함해야합니까?오류 : 'char'앞에 예상 기본 표현
bool yes(char c){
if(c == 'y' || c == 'Y'){
return true;
}
else
return false;
}
int main(){
try{
char c;
cin>>c;
bool yes(char c); //not sure if char c should be here
cout<<"Think of one of these 8 things: ..... Press '|' when you are ready\n";
if(c == '|'){
cout<<"Are you thinking of something big?\n";
cin>>c;
if(yes(char c) == true){ //error here in yes(), trying to call function
cout<<"Are you thinking of something that is alive?\n";
cin>>c;
if(yes(char c) == true){ //error here in yes(), trying to call function
cout<<"Are you thinking of an animal?\n";
cin>>c;
if(yes(char c) == true){ //error here in yes(), trying to call function
cout<<"You are thinking of an elephant.\n";
}
}
}
}
C++의 자습서를 읽고 함수를 호출하는 방법을 배웁니다. 힌트 :'예 (char c)'와는 다릅니다. –
'try'의 목적은 무엇입니까? 또한 if 문에는'== true'가 필요하지 않습니다. –
사소한 일을 단순화하려면 다음 행을 삭제하십시오.'bool yes (char c);'- 예제에서는 아무런 도움이되지 않습니다. – nobar