参考:
http://blog.csdn.net/lins1393997412/article/details/7454817
http://blog.csdn.net/a5161027/article/details/51409845
http://blog.csdn.net/zhouguoqionghai/article/details/46467263
https://msdn.microsoft.com/zh-cn/library/et61xzb3(v=vs.90).aspx
test.h
int fun(int a, int b);
test.cpp
#include "stdafx.h"
#include <iostream>
#include "test.h"
using namespace std;
int fun(int a, int b)
{
return a + b;
}
test2.cpp
#include "stdafx.h"
#include <iostream>
#include "../test/test.h"
using namespace std;
void main()
{
cout << fun(2, 3);
}
test.cpp的配置类型改为静态库(view-property page-configuration-general-project defaults-configuration type-static library)
然后将test2的项目依赖项设置为test,在test2的附加包含目录中找到test1.h所在的文件夹,调试即可(项目依赖项设置:右键项目-properties-common properties-add new reference)(附加包含目录:右键项目-properties-configuration properties-c/c++-Additional include directories)