在input()我调用的 中Table(),我收到一个错误,指出该函数未声明:
#include <iostream>
using namespace std;
void input(){
Table();
}
void Table(){
input();
}
int main(){
input();
Table();
}
Run Code Online (Sandbox Code Playgroud)
在您尝试调用 Table() 时,该函数尚不清楚。添加前向声明以使其工作,如下所示:
using namespace std;
void Table(); // <-- forward declaration
void input(){ Table(); }
void Table(){ input(); }
int main(){ input(); Table(); }
Run Code Online (Sandbox Code Playgroud)