0

In input(), where I call Table(), I get an error that the function is not declared:

#include <iostream>

using namespace std;

void input(){
   Table();
}

void Table(){
   input();
}

int main(){
   input();
   Table();
}
Matthias Grün
  • 1,466
  • 1
  • 7
  • 12
  • Does this answer your question? [C++ Call function that is not defined yet](https://stackoverflow.com/questions/35229198/c-call-function-that-is-not-defined-yet) – adnan_e Aug 29 '21 at 08:26

1 Answers1

5

At the point where you're attempting to call Table(), the function is not known yet. Add a forward declaration to make it work, like so:

using namespace std;

void Table();  // <-- forward declaration

void input(){ Table(); }
void Table(){ input(); }

int main(){ input(); Table(); }
Matthias Grün
  • 1,466
  • 1
  • 7
  • 12