Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

3.3 Substrings

A separate RWCSubString class supports substring extraction and modification. There are no public constructors; RWCSubStrings are constructed indirectly by various member functions of RWCString, and destroyed at the first opportunity.

You can use substrings in a variety of situations. For example, you can create a substring with RWCString::operator(), then use it to initialize an RWCString:

RWCString s("this is a string");
// Construct an RWCString from a substring:
RWCString s2 = s(0, 4);                               // "this"

The result is a string s2 that contains a copy of the first four characters of s.

You can also use RWSubStrings as lvalues in an assignment to a character string, or to an RWCString or RWCSubString:

// Construct an RWCString:
RWCString article("the");
RWCString s("this is a string");
s(0, 4) = "that";                           // "that is a string"
s(8, 1) = article;                        // "that is the string"

Note that assignment to a substring is not a conformal operation: the two sides of the assignment operator need not have the same number of characters.


Previous fileTop of documentContentsIndexNext file
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.