在C++中,可以使用std::string类的.size()或.length()方法来获取长度。 cpp #include <iostream> #include <string> int main() { std::string myString = "Hello, World!"; std::size_t length = myString.size(); // 或者使用 myString.length(); std::cout << "The len...