+ 2

C++ Prototype Declaration not working in my code?

https://code.sololearn.com/cpkwZ1afYcJi/#cpp #include <iostream> #include <string> using namespace std; void allChecked(); void sike(); int main() { string nameString; cout << "What is your name?" << endl; cin >> nameString; if(nameString == "Winson") { int password = 1316; int passwordInteger; cout << "You're awesome ;)" << endl; cout << "What is the password?" << endl; cin >> passwordInteger; if(passwordInteger == password) { string favoriteArtist = "Frank Ocean"; string artistString; cout << "Correct, you may continue." << endl; cout << "Who's your favorite artist?" << endl; cin >> artistString; if(artistString == favoriteArtist) { allPassChecked(); } else { sike(); } } else { cout << "Imposter!" << endl; } } else { cout << "And you are?" << endl; } } void allPassChecked() { cout << "You are you, lol" << endl; } void sike() { cout << "Sike!" << endl; } When I'm declaring the functions as prototype above the main functions, the compiler reacts by saying it is not defined in the scope? Why is this?

21st Feb 2018, 3:20 AM
Winson Dieu
Winson Dieu - avatar
3 Answers
+ 15
Your forward declaration does not match your function allChecked != allPassChecked
21st Feb 2018, 3:30 AM
jay
jay - avatar
+ 13
:) It's an easy mistake to make. Don't feel too bad, we have all made such an error before.
21st Feb 2018, 3:58 AM
jay
jay - avatar
+ 2
That’s embarrassing, thank you! I looked it over and over but for it to be a syntax error...
21st Feb 2018, 3:56 AM
Winson Dieu
Winson Dieu - avatar