I’m sure there’s a simple explanation, but I can’t call functions below some other functions.
int methodOne() {
std::cout << "Method 1";
methodTwo(); //Problem is here. I cannot call methodTwo()
return 0;
}
int methodTwo() {
std::cout << "Method 2";
return 0;
}
int main() {
methodOne();
}
C++ compilers don’t backtrack. You have to declare a function before it is used. The linker can figure out the details later, but you have to let the compiler know about the function first, which is what the forward declaration is for.