when I want to compile I get : Probléme : expected unqualified-id before "return" return 0; about last line : erreur:expexted declaration before { token
I left the code unchanged just the middle part I changed... whats the problem??? here is my code:
#include <iostream>
using namespace std;
int main()
{
cout << "Pensez a un personnage : Mlle Rose, le Professeur Violet, "
<< "le Colonel Moutarde," << endl
<< "le Reverend Olive ou Mme Leblanc." << endl << endl;
cout << "Votre personnage a-t-il des moustaches (1 : oui, 0 : non) ? ";
bool moustaches;
cin >> moustaches;
cout << "Votre personnage porte-t-il des lunettes ? ";
bool lunettes;
cin >> lunettes;
cout << "Votre personnage porte-t-il un chapeau ? ";
bool chapeau;
cin >> chapeau;
cout << "Est-ce que votre personnage est un homme ? ";
bool homme;
cin >> homme;
cout << "==> Le personnage auquel vous pensez est ";
if (chapeau) {
/*******************************************
* Completez le programme a partir d'ici.
*******************************************/
cout << "le Professeur Violet";
else if (moustaches) {
cout << "le Colonel Moutarde";
}
else if (not lunettes) {
cout << "Mlle Rose";
}
else if (homme) {
cout <<"le Révérend Olive";
}
else {
cout <<"Mme Leblanc";
}
/*******************************************
* Ne rien modifier apres cette ligne.
*******************************************/
}
cout << endl;
return 0;
}
----------
Just for the sake of people who landed here for the same reason I did:
Don't use reserved keywords
I named a function in my class definition delete(), which is a reserved keyword and should not be used as a function name. Renaming it to deletion() (which also made sense semantically in my case) resolved the issue.
For a list of reserved keywords: http://en.cppreference.com/w/cpp/keyword
I quote: "Since they are used by the language, these keywords are not available for re-definition or overloading. "
if (chapeau) {
You forgot the ending brace to this if
statement, so the subsequent else if
is considered a syntax error. You need to add the brace when the if
statement body is complete:
if (chapeau) {
cout << "le Professeur Violet";
}
else if (moustaches) {
cout << "le Colonel Moutarde";
}
// ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With