|
Thinking In C++. Volume 2: Practical ProgrammingThis approach saves time and space when strings are used only as value parameters or in other read-only situations. Whether a library implementation uses reference counting or not should be transparent to users of the string class. Unfortunately, this is not always the case. In multithreaded programs, it is practically impossible to use a reference-counting implementation safely.[29]В Creating and initializing C++ strings Creating and initializing strings is a straightforward proposition and fairly flexible. In the SmallString.cpp example in this section, the first string, imBlank, is declared but contains no initial value. Unlike a C char array, which would contain a random and meaningless bit pattern until initialization, imBlank does contain meaningful information. This string object is initialized to hold "no characters" and can properly report its zero length and absence of data elements through the use of class member functions. The next string, heyMom, is initialized by the literal argument "Where are my socks?" This form of initialization uses a quoted character array as a parameter to the string constructor ...» |
Код для вставки книги в блог HTML
phpBB
текст
|
|