- Build class String
- To handle String creation, manipulation
- Class string in standard library (more Chapter 15)
- Conversion constructor
- Single-argument constructor
- Turns objects of other types into class objects
- String s1("hi");
- Creates a String from a char *
- Any single-argument constructor is a conversion constructor
The programs of Figs. 3.12-3.21 demonstrates the building of our own String class to handle the creation and manipulation
of strings.
Figure 3.12:
String class definition with operator overloading. (part 1 of 2)
|
Figure 3.13:
String class definition with operator overloading. (part 2 of 2)
|
Figure 3.14:
String class member-function and friend-function definition. (part 1 of 4)
|
Figure 3.15:
String class member-function and friend-function definition. (part 2 of 4)
|
Figure 3.16:
String class member-function and friend-function definition. (part 3 of 4)
|
Figure 3.17:
String class member-function and friend-function definition. (part 4 of 4)
|
Figure 3.18:
String class test program. (part 1 of 2)
|
Figure 3.19:
String class test program. (part 2 of 2)
|
Figure 3.20:
String class test program, output. (part 1 of 2)
|
Figure 3.21:
String class test program, output. (part 2 of 2)
|
2004-07-29