2014-02-13 63 views
0

我已經編寫如下:C++:STD沒有成員「串」

STDMETHODIMP CWrapper::openPort(LONG* m_OpenPortResult) 
{ 
    std::string str; 
    //const char * c = str.c_str(); 
    // Open("test".c_str()) 

    return S_OK; 
} 

編譯器告訴我:「有沒有這樣的成員‘串’在命名空間std」。

我包括這個樣子:

#include "stdafx.h" 
#include "Wrapper.h" 
#include <string.h> 
using namespace std; 

難道我做錯什麼事這麼遠?

+2

你#包括? –

+2

'string'和'string.h'是兩個不同的頭文件。 – olevegard

+0

@olevegard啊,是的,超級。現在,我使用包括,它的工作原理。 – tmighty

回答

1

您需要添加以下內容:

#include <string>