我有嘗試的typedef自己一個很好的方便tstring問題(見下文)問題與tstring的typedef
#ifndef _NISAMPLECLIENT_H_
#define _NISAMPLECLIENT_H_
#include <windows.h>
#include <stdlib.h>
using namespace std; // ERROR here (1)
#ifdef _UNICODE
#define CommandLineToArgv CommandLineToArgvW
#else
#define CommandLineToArgv CommandLineToArgvA
#endif
typedef basic_string<TCHAR> tstring; // ERROR HERE (2)
試圖編譯這個時候我得到一個編譯錯誤。在Error 「錯誤在這裏(1)」 是:
Error 3 error C2871: 'std' : a namespace with this name does not exist \nisampleclient\nisampleclientdefs.h 16
如果我刪除using namespace std;
聲明,並更改錯誤HERE(2)說typedef std::basic_string<TCHAR> tstring;
然後我得到一個錯誤:
Error 3 error C2653: 'std' : is not a class or namespace name \nisampleclient\nisampleclientdefs.h 23
在那改爲點。
在此先感謝。 :)
我其實已經嘗試了另一種方式。 「使用命名空間......」是我最後希望的堡壘。 包含string.h沒有區別。不過謝謝。 – Dennis 2011-02-24 15:19:07
我沒有編寫'string.h',我寫了'string';)... C++項目中的'string.h'通常會變成'cstring'。 – 0xC0000022L 2011-02-24 15:21:12
你是在現場。問題其實是我使用string.h而不是字符串。耶布斯! – Dennis 2011-02-24 15:26:51