The String class in this chapter provides an overloaded operator()() for substrings as rvalues only. Recall that the notation s(position,count) is a substring of length count characters, starting with position in String s (position starts at 0). Now let's look at an example with substrings as lvalues and rvalues.
String s1 = "alphabet"; cout << s1(5,3) << endl; // rvalue - substring "bet" s1(5,3) = "ray"; // lvalue - s1 is now "alpharay"
We also need to make lvalues behave properly for constant substrings.
const String s2 = "alphabet"; // constant String cout << s2(5,3) << endl; // rvalue - substring "bet" s2(5,3) = "ray"; // lvalue - error, s2 is constant
Substrings are interesting ...