| delorie.com/archives/browse.cgi | search |
| From: | "John Harrison" <jahhaj AT dtn DOT ntl DOT com> |
| Newsgroups: | comp.os.msdos.djgpp,comp.lang.c++ |
| References: | <3952E8D5 DOT 4A5F0B58 AT hotmail DOT com> |
| Subject: | Re: more problems with string class |
| Lines: | 35 |
| X-Priority: | 3 |
| X-MSMail-Priority: | Normal |
| X-Newsreader: | Microsoft Outlook Express 5.00.2919.6600 |
| X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2919.6600 |
| Message-ID: | <ZDC45.7800$_55.168969@news2-win.server.ntlworld.com> |
| Date: | Fri, 23 Jun 2000 06:35:07 +0100 |
| NNTP-Posting-Host: | 194.168.245.221 |
| X-Complaints-To: | abuse AT net DOT ntl DOT com |
| X-Trace: | news2-win.server.ntlworld.com 961738361 194.168.245.221 (Fri, 23 Jun 2000 06:32:41 BST) |
| NNTP-Posting-Date: | Fri, 23 Jun 2000 06:32:41 BST |
| Organization: | ntl News Service |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
"Heavy" <heavier AT hotmail DOT com> wrote in message
news:3952E8D5 DOT 4A5F0B58 AT hotmail DOT com...
> Hi, I'm having more problems with the string class. I am using <string>,
> but am finding that the class string has very little useful
> functionality. I'm wondering if I'm missing something, or if I'm
> supposed to create a subclass of string to add methods to acquire
> substrings of the main string (i.e. a before(pos) method to return a
> string containing the left part of a string).
>
before(pos) == substr(0, pos)
If you're desperate to use before then try writing an inline function
inline std::string before(const std::string& str, std::string::size_type
pos) { return str.substr(0, pos); }
This is a better approach than deriving from string since string was not
designed to be derived from (it doesn't have a virtual destructor for
instance).
I'd be interested to know what other methods you think string is missing.
john
> I must be missing something, because I can't see creating a subclass of
> string every time you need a little less generic functionality.
>
> Any information you could provide for me would be useful, thanks
>
> Heavy
> heavier AT hotmail DOT com
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |