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

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

1,头文件 x.h:

1  int f();

2,实现 impl.cpp:

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 }

 

posted @ 2018-01-02 18:09  wonkju  阅读(1117)  评论(0编辑  收藏  举报