placement new to defer to a different constructor
Posted
by Jonathan Swinney
on Stack Overflow
See other posts from Stack Overflow
or by Jonathan Swinney
Published on 2010-04-19T14:24:30Z
Indexed on
2010/04/19
14:33 UTC
Read the original article
Hit count: 169
c++
Is this safe? I'm not using any virtual functions in my actual implementation, but I'm tempted to believe that even if I was, it would still be safe.
class Foo
{
Foo()
{
// initialize things
}
Foo( int )
{
new ( this ) Foo();
}
}
© Stack Overflow or respective owner