c++中如何在主函数中调用其他文件内的函数

如题所述

第1个回答  2018-06-09
extern声明一下

f1.cpp
int fun()
{
cout<<"fun";
return 0;
}
main.cpp
#include"f1.cpp"//包含
#include<iostream>
using namespace std;
int main()
{
extern int fun();//声明
fun();//调用
return 0;
}本回答被网友采纳
相似回答