On Feb 28, 7:25 pm, Phil Endecott <spam_from_usen et_0...@chezphi l.org>
wrote:
Sebastian Nibisz wrote:
or
struct node
{ boost::shared_p tr<nodenext;
};
{
for (int x = 0; x < 1000000; ++x)
{
n = n->next = shared_ptr<node >(new node);
}
} // <- STACK OVERFLOW
Why?
You're kidding us, right?
Eric was obviously being facious with his suggestion, since it
obviously wouldn't work; I can't imagine anyone not spotting the
problem immediately. The trick about shared_ptr, here, of
course, is that you don't see the recursion, so you may not
realize that you have the same problem until someone explicitly
asks what will happen.
It's really pretty rare that you can recurse 1000000 times
without the stack overflowing.
--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34