【发布时间】:2020-08-17 10:42:02
【问题描述】:
我目前正在使用 C++ 进行试验,我想知道如何在 main 中调用下面提到的 fun1:
#include <iostream>
int main() {
std::cout << "Result is: " << fun1(1, 4, 1)();
}
int fun1(int x, int y, int z) {
some stuff
}
我在 fun1 的 main 上遇到错误:
clang++-7 -pthread -std=c++17 -o main main.cpp
main.cpp:4:33: error: use of undeclared identifier 'fun1'
std::cout << "Result is: " << fun1(1, 4, 1)();
^
1 error generated.
compiler exit status 1
有人可以帮忙解决如何调用 fun1,谢谢。
【问题讨论】:
-
删除 () 应该只是 fun1(1,4,1)。并且您还需要在 main 上方有函数声明
-
@OmidCompSCI 仍然会导致 fun1 出现错误。嗯
标签: c++