August 2012
Intermediate to advanced
976 pages
30h 17m
English
stringsEach class defines how objects of its type can be initialized. A class may define many different ways to initialize objects of its type. Each way must be distinguished from the others either by the number of initializers that we supply, or by the types of those initializers. Table 3.1 lists the most common ways to initialize strings. Some examples:
string s1; // default initialization; s1 is the empty stringstring s2 = s1; // s2 is a copy of s1string s3 = "hiya"; // s3 is a copy of the string literalstring s4(10, 'c'); // s4 is cccccccccc
Table 3.1. Ways to Initialize a string
Read now
Unlock full access