1 | static const wchar_t*g_str1 = … |
2 | static const wchar_t*g_str2 = … |
1 | //Header.h |
2 | #pragma once |
3 |
4 | static int g_int= 3; |
1 | //Functions.h |
2 | #pragma once |
3 |
4 | void TestSource1(); |
5 | void TestSource2(); |
01 | //Source1.cpp |
02 | #include<stdio.h> |
03 | #include "Header.h" |
04 |
05 | void TestSource1() { |
06 |
07 | wprintf(L"g_int's address in Source1.cpp:x\n",&g_int); |
08 | g_int = 5; |
09 | wprintf(L"g_int's value in Source1.cpp:%d\n", g_int); |
10 | } |
1 | //Source2.cpp |
2 | #include<stdio.h> |
3 | #include "Header.h" |
4 |
5 | void TestSource2() { |
6 |
7 | wprintf(L"g_int's address in Source2.cpp:x\n",&g_int); |
8 | wprintf(L"g_int's value in Source2.cpp:%d\n", g_int); |
9 | } |
1 | //Main.cpp |
2 | #include "Functions.h" |
3 |
4 | int wmain() { |
5 |
6 | TestSource1(); |
7 | TestSource2(); |
8 | } |
1 | //Header.h |
2 | #pragma once |
3 |
4 | extern int g_int; |
01 | //Source1.cpp |
02 | #include<stdio.h> |
03 | #include "Header.h" |
04 |
05 | int g_int= 3; |
06 |
07 | void TestSource1() { |
08 |
09 | wprintf(L"g_int's address in Source1.cpp:x\n",&g_int); |
10 | g_int = 5; |
11 | wprintf(L"g_int's value in Source1.cpp:%d\n", g_int); |
12 | } |
歡迎光臨 (http://www.torrancerestoration.com/bbs/) | Powered by Discuz! X3.1 |