C++: std 没有成员 "string"

标签 c++ string visual-studio-2012 c++11 namespaces

我编写了以下代码:

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;

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

最佳答案

您需要添加以下内容:

#include <string>

关于C++: std 没有成员 "string",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21767053/

相关文章:

c++ - 如何在 OpenGL 中设置顶点的不透明度?

c++ - 将奇怪的十六进制电话号码转换为普通数字

c++ - 2wd 蓝牙控制汽车无法停止的问题

javascript - 在javascript中测试2个字符串之间的常用词

c# - 我们可以只对所有单元测试类使用一个 ClassInitialize 吗?

html - 无法编辑 'URL'。样式表必须是项目的一部分

c++ - View ::istream 或范围::istream_view 的语法是否正确?

java - 如何改变字符串中字符的位置?

使用 while 循环连接两个数组

.net - Windows 7 和 8 中的不同 .NET 4.5?