6、C++ 静态编译链接使用库

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sxj731533730/article/details/84345505

直接上例子:存在三个文件

 example.cpp中的文件

#include<iostream>
#include"function.h"
using namespace std;
int fun(int a,int b);
int main()
{
cout<<fun(2,3)<<endl;
cout<<"hello world"<<endl;
return 0;
}

function.cpp

                                                                                                                     
"example.cpp" 11L, 158C written
hello world
#include<iostream>
#include "function.h"
int fun(int a,int b)
{
return a+b;
}

function.h

#include<iostream>
int fun(int a,int b);

有关详细知识可以参看官方手册;

猜你喜欢

转载自blog.csdn.net/sxj731533730/article/details/84345505
今日推荐