1
这里是我的main.cpp:如何使用extern链接到其他cpp文件中的函数?
#include <iostream>
#include "function.cpp"
using namespace std;
extern int giveMain();
int main() {
int x = 4;
x = giveMain(x);
cout << x << endl;
}
这里是我的function.cpp:
#include <iostream>
using namespace std;
int giveMain(int a) {
a = 3 + a;
return a;
}
但是当我编译,它说: “连接命令失败”。任何人都可以帮助我解决这个问题。