Why can't I declare a string in my program: “string is undeclared identifier”

前端 未结 3 1106
粉色の甜心
粉色の甜心 2021-01-12 07:12

I can\'t declare a string in my program:

string MessageBoxText = CharNameTextBox->Text;

it just doesn\'t work. It says string is u

3条回答
  •  迷失自我
    2021-01-12 07:59

    To use the standard string class in C++ you need to #include . Once you've added the #include directive string will be defined in the std namespace and you can refer to it as std::string.

    E.g.

    #include 
    #include 
    
    int main()
    {
        std::string hw( "Hello, world!\n" );
        std::cout << hw;
        return 0;
    }
    

提交回复
热议问题