Hello everyone,
Two questions,
1.
The following compiler error from the following code segment, is because delete statement from destructor of auto_ptr requires the declaration of destructor of wrapped object?
2.Code:1>main.cpp 1>d:\visual studio 2008\projects\test_autoptr2\test_autoptr2\main.cpp(10) : error C2512: 'Foo' : no appropriate default constructor available #include <memory> #include <iostream> using namespace std; class Foo; void func() { auto_ptr<Foo> pf (new Foo()); cout << "I am here. " << endl; return; } int main() { func(); return 0; } class Foo { };
If yes, how to define a destructor outside of the body of class declaration? I defined in this way, but compile can not pass.
Code:Foo::~Foo() { }
thanks in advance,
George