2013-03-12 55 views
0

我在一個非常簡單的頭文件中收到C2143錯誤。你能幫我找到問題嗎?錯誤C2143 VC++ 12

#ifndef GLOB_H_INCLUDED 
#define GLOB_H_INCLUDED 
#include <string> 
#include <windows.h> 

extern string *name, *surname, *dob, *hospNo, *addr, *sex, *email, *phone, *nhs, *allerg, *indic, *notes; 
extern int leftc, rightc, middlec; 
extern string ks; 

#endif 

如果您需要進一步解釋任何事情......提前致謝。

回答

1

嘗試增加using namespace std;的包括字符串頭:)

+0

向另一個頭添加'using'語句並不好 - 它強制整個名稱空間進入任何包含該頭的代碼的範圍。 – 2013-03-13 11:36:17

+0

@roger_rowland我完全同意你的觀點,我的意圖是提供問題的快速解決方案,而不會對C++最着名的方法潛心鑽研:-) – 2013-03-13 11:41:54

0

你錯過了「STD」命名空間後 - 但不是增加一個「使用」的條款,以你的頭文件(這是不好的做法),像這樣限定你的名字:

#ifndef GLOB_H_INCLUDED 
#define GLOB_H_INCLUDED 
#include <string> 
#include <windows.h> 

extern std::string *name, *surname, *dob, *hospNo, *addr, *sex, *email, *phone, *nhs, *allerg, *indic, *notes; 
extern int leftc, rightc, middlec; 
extern std::string ks; 

#endif