fatal error LNK1169: 找到一个或多个多重定义的符号

在vs中,使用c时,由编译-连接,cpp之间是自动的,如:spa

1,头文件 x.h:code

1  int f();

2,实现 impl.cpp:blog

1 #include "stdafx.h"
2 
3 int f() {
4     return 1;
5 }

3,在main(即user_extern.cpp)中(使用实现 impl.cpp不须要include  impl.cpp),只要include 包含  int f();的 头文件(即 x.h)编译

 1 // user_extern.cpp : 定义控制台应用程序的入口点。
 2 //
 3 
 4 #include "stdafx.h"
 5 #include "x.h"
 6 
 7 
 8 int _tmain(int argc, _TCHAR* argv[])
 9 {
10     int i= f();
11     printf("%d",i);
12     return 0;
13 }
相关文章
相关标签/搜索