C++: std does not have member "string"

11,719

You need to add the following:

#include <string>
Share:
11,719
tmighty
Author by

tmighty

Updated on June 22, 2022

Comments

  • tmighty
    tmighty almost 2 years

    I have coded the following:

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

    The compiler tells me "There is no such member "string" in the namespace std".

    My includes look like this:

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

    Did I do anything wrong so far?