C++ C++;:std没有成员“;“字符串”;
我已编写了以下代码:C++ C++;:std没有成员“;“字符串”;,c++,string,visual-studio-2012,c++11,namespaces,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; } #include <string> 编译器告诉我“名称空间std中没有这样的成员”字符串” 我的附件如下所示: #include "st
STDMETHODIMP CWrapper::openPort(LONG* m_OpenPortResult)
{
std::string str;
//const char * c = str.c_str();
// Open("test".c_str())
return S_OK;
}
#include <string>
编译器告诉我“名称空间std中没有这样的成员”字符串”
我的附件如下所示:
#include "stdafx.h"
#include "Wrapper.h"
#include <string.h>
using namespace std;
#包括“stdafx.h”
#包括“Wrapper.h”
#包括
使用名称空间std;
到目前为止我做错了什么吗?您需要添加以下内容:
STDMETHODIMP CWrapper::openPort(LONG* m_OpenPortResult)
{
std::string str;
//const char * c = str.c_str();
// Open("test".c_str())
return S_OK;
}
#include <string>
#包括
include吗?string
和string.h
是两个不同的头文件。@olevegard啊,是的,太棒了。现在我使用include,它就可以工作了。