C++:std没有成员“string”。

13

我已经编写了以下代码:

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

    return S_OK;
}

编译器告诉我"命名空间std中没有这样的成员“string”"。

我的头文件包含如下:

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

我到目前为止做错了什么吗?


2
你是否包含了 <string> 库? - Andy Thomas
2
stringstring.h是两个不同的头文件。 - olevegard
@olevegard 啊,是的,太棒了。现在我使用 include <string>,它可以工作了。 - tmighty
1个回答

29

您需要添加以下内容:

#include <string>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接