- 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. 1-10 demonstrates the building of our own String class to handle the creation and manipulation
of strings.
Figure 1:
String class definition with operator overloading. (part 1 of 2)
|
Figure 2:
String class definition with operator overloading. (part 2 of 2)
|
Figure 3:
String class member-function and friend-function definition. (part 1 of 4)
|
Figure 4:
String class member-function and friend-function definition. (part 2 of 4)
|
Figure 5:
String class member-function and friend-function definition. (part 3 of 4)
|
Figure 6:
String class member-function and friend-function definition. (part 4 of 4)
|
Figure 7:
String class test program. (part 1 of 2)
|
Figure 8:
String class test program. (part 2 of 2)
|
Figure 9:
String class test program, output. (part 1 of 2)
|
Figure 10:
String class test program, output. (part 2 of 2)
|
2004-07-15