C++字符串声明

Net*_*nfo 12 c++ string

我一直在用VB工作一段时间.现在我给C++一个镜头,我遇到了字符串,我似乎找不到声明字符串的方法.

例如在VB中:

Dim Something As String = "Some text"
Run Code Online (Sandbox Code Playgroud)

要么

Dim Something As String = ListBox1.SelectedItem
Run Code Online (Sandbox Code Playgroud)

什么相当于C++中的上述代码?

任何帮助表示赞赏.

das*_*ght 24

C++提供了一个string可以像这样使用的类:

#include <string>
#include <iostream>

int main() {
    std::string Something = "Some text";
    std::cout << Something << std::endl;
}
Run Code Online (Sandbox Code Playgroud)