Topic: string and substring design
Author: Edward Diener <70304.2632@CompuServe.COM>
Date: 15 Mar 1995 00:19:21 GMT Raw View
>By having a substring object that contains a reference to the
>original string you can write code like this:
> string s = "abcd";
> s(1,2) = "insert this text";
> cout << s;
Why can't the operator be:
const string operator()(size_t start,size_t len) const;
rather than the way it is:
const TSubString operator()(size_t start,size_t len) const;
That's the gist of my original question.
Author: pstemari@erinet.com (Paul J. Ste. Marie)
Date: Wed, 15 Mar 95 03:58:44 GMT Raw View
In article <3k5bq9$eho$2@mhadg.production.compuserve.com>,
Edward Diener <70304.2632@CompuServe.COM> wrote:
:> string s = "abcd";
:> s(1,2) = "insert this text";
:> cout << s;
:
:Why can't the operator be:
:
:const string operator()(size_t start,size_t len) const;
:
:rather than the way it is:
:
:const TSubString operator()(size_t start,size_t len) const;
:
:That's the gist of my original question.
Because then the above code would have to be:
s = s(0,1) + "insert this text" + s(3,1)
The substring class lets you modify a portion of the string in
place.
Author: pete@borland.com (Pete Becker)
Date: Mon, 13 Mar 95 17:31:18 PST Raw View
In article <3jsud3$g42$1@mhadg.production.compuserve.com>,
70304.2632@CompuServe.COM says...
>
>Does anyone understand why a TSubString was invented in reference
>to the C++ string class ? I don't see the difference between a
>TSubString a a string, other than that the functionality of a
>TSubString is much more limited. Why, for instance, couldn't the
>string::substring functions just return another string ? What's
>the point of this TSubString ? Any elucidation on this matter
>of C++ design of the string class would be appreciated .
By having a substring object that contains a reference to the original
string you can write code like this:
string s = "abcd";
s(1,2) = "insert this text";
cout << s;
Author: Edward Diener <70304.2632@CompuServe.COM>
Date: 11 Mar 1995 19:41:23 GMT Raw View
Does anyone understand why a TSubString was invented in reference
to the C++ string class ? I don't see the difference between a
TSubString a a string, other than that the functionality of a
TSubString is much more limited. Why, for instance, couldn't the
string::substring functions just return another string ? What's
the point of this TSubString ? Any elucidation on this matter
of C++ design of the string class would be appreciated .