•[FooFactory.C]
#include
"FooFactory.H"
#include "Foo.H"
Foo*
FooFactory::createBadFoo(int a, int b) {
Foo
LocInst (a,b); // creates an local instance of class Foo
return
& LocInst; // returns a pointer to this instance
} // ERROR! LocInst leaves scope
// and it is destroyed!