In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
C++ string class how to use, many novices are not very clear, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
1. Advantages of using the string class
In C++, a string is an array of characters. The simplest array of characters can be defined as follows:
Char staticArray [20]; / / declares a fixed-length array of static characters
The length of such a static array is fixed. In many practical problems, the length of the character array we define cannot be determined in advance, so we want to declare a dynamic character array and dynamically adjust the array length according to the needs of the program.
The string class provides us with such a shortcut, which can not only dynamically resize according to the needs of the program, but also provide a lot of useful member functions (methods) to help manipulate strings more easily.
two。 Initialization and basic application
The string class provides many overloaded constructors, so you can initialize and instantiate in a variety of ways.
# include # include using namespace std;int main () {/ / 1. Several ways to initialize a string string str1 = "Study String!"; / / initialize a string string str2 ("Study String!"); / / initialize, essentially calling the overloaded constructor of the string class to initialize string str3 (str1); / / copy str3 to str1 cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.