This should be a really simple question, but I haven't used C++ in a while and I don't remember how to handle this Code: #include <iostream> #include <memory> class test { std::auto_ptr<int> a; public: test(int *ptr) : a(ptr) { } }; test make_test() { test x(new int(4)); return x; } int main() { test x = make_test(); return 0; } Compiler output: Code: In function 'int main()':| 20|error: no matching function for call to 'test::test(test)'| 9|note: candidates are: test::test(int*)| 5|note: test::test(test&)| ||=== Build finished: 1 errors, 0 warnings ===| What's the right way to do this? I guess the class "test" is not copyable because of the auto_ptr<int>, but even then I don't know what to do. One thing may be returning an auto_ptr<Test> from make_test, but is there any way to avoid this memory allocation?