auto_ptr compile error

Joined
Feb 12, 2008
Messages
108
Reaction score
0
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?

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 {
};

2.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,690
Latest member
MacGyver

Latest Threads

Top