開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
為了方便將1個DWORD拆成4個byte處理,我製做了一個集合:
union UserType
{
unsigned char _BYTE[4];
unsigned int _DWORD;
};
然後有一個專案中用到"FuncA.cpp"、"FuncB.cpp"、"FuncC.cpp",
且三個檔案中都會用到上述集合,一種作法是將該集合製作出新的
檔案"UserType.h"然後讓三個檔案都引用"UserType.h"。
但除此之外,有沒有辦法讓"FuncA.cpp"、"FuncB.cpp"、"FuncC.cpp"
都在內部定義"UserType"這個集合,並且讓編譯器知道當宣告"UserType"
型態變數的時候,是指該檔案中自己的"UserType"。
我試著再union前加入static,但似乎沒效果,編譯器還是跑出重複定義
的錯誤。
餵入的資料(Input):
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
程式碼(Code):(請善用置底文網頁, 記得排版)
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 211.72.212.239
推
05/05 16:03, , 1F
05/05 16:03, 1F
→
05/05 16:10, , 2F
05/05 16:10, 2F
→
05/05 16:35, , 3F
05/05 16:35, 3F
→
05/05 16:37, , 4F
05/05 16:37, 4F
→
05/05 16:39, , 5F
05/05 16:39, 5F
→
05/05 16:40, , 6F
05/05 16:40, 6F
→
05/05 16:41, , 7F
05/05 16:41, 7F
→
05/05 16:41, , 8F
05/05 16:41, 8F
→
05/05 16:42, , 9F
05/05 16:42, 9F
→
05/05 16:42, , 10F
05/05 16:42, 10F
推
05/05 19:34, , 11F
05/05 19:34, 11F
→
05/05 19:35, , 12F
05/05 19:35, 12F