更新时间:2023-11-17 10:42:34
您需要在main之前提到重载calcPostage函数的函数原型,这将解决问题.
You need to mention the function prototype for overloaded calcPostage functions before main,that will solve the issue.
编译器从源文件的顶部到底部开始工作.
函数原型是对将要存在的函数的定义,因此编译器知道不会使代码编译失败.
如果发现尚未定义的功能,它将失败,以同样的方式,如果定义了两次,则将失败.
正如Harish所说的那样:
int calcPostage(int);
int calcPostage(int,int,int);
在main将要修复代码之前,以便编译器知道这些功能将在代码的将来存在.
The compiler works from the top of a source file to the bottom.
A function prototype is a definition of the function that will exist and so the compiler knows not to fail the code compile.
If it finds a function that is not defined already it will fail, in the same way it will fail if a function is defined twice.
As Harish has said putting:
int calcPostage(int);
int calcPostage(int,int,int);
before the main will fix the code so that the compiler knows that these function will exist at some point in the future in the code.