1 | ########################################
|
---|
2 | # nested.h
|
---|
3 | ########################################
|
---|
4 |
|
---|
5 | #pragma once
|
---|
6 |
|
---|
7 | static inline void function()
|
---|
8 | {
|
---|
9 | class Nested
|
---|
10 | {
|
---|
11 | Nested(){
|
---|
12 | }
|
---|
13 | ~Nested()
|
---|
14 | {}
|
---|
15 | };
|
---|
16 | }
|
---|
17 |
|
---|
18 | ########################################
|
---|
19 | # first_source.cpp
|
---|
20 | ########################################
|
---|
21 |
|
---|
22 | #include "nested.h"
|
---|
23 |
|
---|
24 | void first_caller()
|
---|
25 | {
|
---|
26 | function();
|
---|
27 | }
|
---|
28 |
|
---|
29 | ########################################
|
---|
30 | # second_source.cpp
|
---|
31 | ########################################
|
---|
32 |
|
---|
33 | #include "nested.h"
|
---|
34 |
|
---|
35 | void second_caller()
|
---|
36 | {
|
---|
37 | function();
|
---|
38 | }
|
---|
39 |
|
---|
40 | ########################################
|
---|
41 | # output
|
---|
42 | ########################################
|
---|
43 |
|
---|
44 | 1>------ Build started: Project: NestedTest, Configuration: Debug Win32 ------
|
---|
45 | 1>Compiling...
|
---|
46 | 1>first_source.cpp
|
---|
47 | 1>second_source.cpp
|
---|
48 | 1>Generating Code...
|
---|
49 | 1>Linking...
|
---|
50 | 1>second_source.obj : error LNK2005: "private: __thiscall `void __cdecl function(void)'::`2'::Nested::Nested(void)" (??0Nested@?1??function@@YAXXZ@AAE@XZ) already defined in first_source.obj
|
---|
51 | 1>second_source.obj : error LNK2005: "private: __thiscall `void __cdecl function(void)'::`2'::Nested::~Nested(void)" (??1Nested@?1??function@@YAXXZ@AAE@XZ) already defined in first_source.obj
|
---|
52 | 1>C:\Users\Administrator\Desktop\NestedTest\Debug\NestedTest.dll : fatal error LNK1169: one or more multiply defined symbols found
|
---|
53 | 1>Build log was saved at "file://c:\Users\Administrator\Desktop\NestedTest\NestedTest\Debug\BuildLog.htm"
|
---|
54 | 1>NestedTest - 3 error(s), 0 warning(s)
|
---|
55 | ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
---|