Hmm, I guess pass-by-value a Copy Constructor doth not make.
Solution #1 -------------------------------- #include <memory>
using namespace std;
class Foo { public: Foo(Foo const& in); private: auto_ptr<int> m; };
Foo::Foo(Foo const& in) : m(const_cast<Foo&>(in).m) { }
Foo FooFactory(); int main() { Foo f(FooFactory()); Foo f2 = FooFactory(); } --------------------------------
Solution #2 -------------------------------- #include <memory>
using namespace std;
class Foo { public: Foo(Foo const& in); private: mutable auto_ptr<int> m; };
Foo::Foo(Foo const& in) : m(in.m) { }
Foo FooFactory(); int main() { Foo f(FooFactory()); Foo f2 = FooFactory(); } --------------------------------
HTH. --Eljay