T
tcl
Questions on ostrstream.
#1) do I have a memory leak as the control exits the scope
{
ostrstream os;
os << "hello world" << endl << ends;
}
#2) if there's no memory leak in #1, is there a leak here:
{
ostrstream os;
os << "hello world" << endl << ends;
cout << os.str();
}
#3) if there's a memory leak in either #1 or #2, would adding
either of the following statements right before exiting
the scope fix it? if not, how to fix it?
os.freeze(0);
delete [] os;
Thanks,
tcl
#1) do I have a memory leak as the control exits the scope
{
ostrstream os;
os << "hello world" << endl << ends;
}
#2) if there's no memory leak in #1, is there a leak here:
{
ostrstream os;
os << "hello world" << endl << ends;
cout << os.str();
}
#3) if there's a memory leak in either #1 or #2, would adding
either of the following statements right before exiting
the scope fix it? if not, how to fix it?
os.freeze(0);
delete [] os;
Thanks,
tcl