Hello everyone,


I posted the code and related compile error below. My analysis below,

1. I think the reason of compile error is, the copy constructor of Goo accepts const reference as input parameter, so the pf member of input parameter is also treated const?
2. And since auto_ptr does not have a copy constructor which accepts const reference auto_ptr as input parameter, the compile error occurs.

My analysis (1) and (2) are both correct?

What makes me confused is it seems the compile error message does not reflect my analysis (1) and (2) above. Any ideas?

Code:
#include <memory>

using namespace std;

// Foo is Pimpl class for Goo, suppose.
class Foo {

};

class Goo {

public:

	auto_ptr<Foo> pf;

	Goo (const Goo& input)
	{
		this -> pf = input.pf;
	}
};

1>d:\visual studio 2008\projects\test0330\test0330\main.cpp(18) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'const std::auto_ptr<_Ty>' (or there is no acceptable conversion)
1> with
1> [
1> _Ty=Foo
1> ]
1> d:\program files\microsoft visual studio 9.0\vc\include\memory(689): could be 'std::auto_ptr<_Ty> &std::auto_ptr<_Ty>:perator =<Foo>(std::auto_ptr<_Ty> &) throw()'
1> with
1> [
1> _Ty=Foo
1> ]
1> d:\program files\microsoft visual studio 9.0\vc\include\memory(701): or 'std::auto_ptr<_Ty> &std::auto_ptr<_Ty>:perator =(std::auto_ptr<_Ty> &) throw()'
1> with
1> [
1> _Ty=Foo
1> ]
1> d:\program files\microsoft visual studio 9.0\vc\include\memory(707): or 'std::auto_ptr<_Ty> &std::auto_ptr<_Ty>:perator =(std::auto_ptr_ref<_Ty>) throw()'
1> with
1> [
1> _Ty=Foo
1> ]
1> while trying to match the argument list '(std::auto_ptr<_Ty>, const std::auto_ptr<_Ty>)'
1> with
1> [
1> _Ty=Foo
1> ]


thanks in advance,
George