[lug] C++ libraries in Linux
Keith Brown
kbrown8 at uswest.net
Tue Sep 18 10:42:13 MDT 2001
I hate to reply to my own mail, but my example is not correct. The buf should be
unfrozen with buf.freeze(false), at least according to Josuttis. Additionally,
strstream has been depreciated and he suggest you use stringstream.
Keith
Keith Brown wrote:
> Hi,
>
> I believe you have memory leak in your example. Once you do buf.str(), the
> program owns the *char that is returned, unless it tells strstream otherwise,
> which I forget how to do. I believe you need to do it like:
>
> char * s = buf.str();
> rtnval = s;
> delete [] s;
> return rtnval;
>
> Keith
>
> "Scott A. Herod" wrote:
>
> > Hi,
> > I use something like the following:
> >
> > #include
> > <strstream>
> > string paraNode::toString()
> > {
> > string rtnval;
> > strstream buf;
> >
> > buf << "Paragraph: "
> > << ATTR_ALIGN << " = " << _align << ", "
> > << ATTR_WRAP_MODE << " = " << _mode
> > << ends;
> >
> > rtnval = buf.str();
> > return rtnval;
> > }
> >
> > > Can it be true? There are no converters to go from an int to a string? Or
> > > a double to a string?
> > >
> > > --Keith
> > _______________________________________________
> > Web Page: http://lug.boulder.co.us
> > Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
>
> --
> Keith Brown
> 12640 Xavier St
> Broomfield, CO 80020
> 303.438.8169
>
> _______________________________________________
> Web Page: http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
--
Keith Brown
12640 Xavier St
Broomfield, CO 80020
303.438.8169
More information about the LUG
mailing list