Click here to Skip to main content
15,904,655 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Getting the information, if a softwrare is "running as administartor" (C++ / Windows Vista) Pin
JudyL_MD31-Mar-08 5:00
JudyL_MD31-Mar-08 5:00 
AnswerRe: Getting the information, if a softwrare is "running as administartor" (C++ / Windows Vista) Pin
graypx24-Jun-08 6:12
graypx24-Jun-08 6:12 
GeneralSTA component call MTA component Pin
George_George30-Mar-08 3:38
George_George30-Mar-08 3:38 
Generalgetting pixel(s) directly from the screen Pin
shja8830-Mar-08 3:26
shja8830-Mar-08 3:26 
GeneralRe: getting pixel(s) directly from the screen Pin
CPallini30-Mar-08 3:53
mveCPallini30-Mar-08 3:53 
GeneralRe: getting pixel(s) directly from the screen Pin
shja8830-Mar-08 4:13
shja8830-Mar-08 4:13 
QuestionRe: getting pixel(s) directly from the screen Pin
Hamid_RT7-Apr-08 2:31
Hamid_RT7-Apr-08 2:31 
Generalauto_ptr assignment compile error Pin
George_George30-Mar-08 0:51
George_George30-Mar-08 0:51 
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?

#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>::operator =<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>::operator =(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>::operator =(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
GeneralRe: auto_ptr assignment compile error Pin
CPallini30-Mar-08 1:33
mveCPallini30-Mar-08 1:33 
GeneralRe: auto_ptr assignment compile error Pin
George_George30-Mar-08 2:38
George_George30-Mar-08 2:38 
GeneralRe: auto_ptr assignment compile error Pin
CPallini30-Mar-08 2:43
mveCPallini30-Mar-08 2:43 
GeneralRe: auto_ptr assignment compile error Pin
George_George30-Mar-08 2:49
George_George30-Mar-08 2:49 
Generalthe debug problem in VC++ Pin
wendyyue29-Mar-08 23:19
wendyyue29-Mar-08 23:19 
GeneralRe: the debug problem in VC++ Pin
Cedric Moonen29-Mar-08 23:51
Cedric Moonen29-Mar-08 23:51 
GeneralRe: the debug problem in VC++ Pin
rp_suman30-Mar-08 1:06
rp_suman30-Mar-08 1:06 
GeneralRe: the debug problem in VC++ Pin
Saurabh.Garg30-Mar-08 1:59
Saurabh.Garg30-Mar-08 1:59 
GeneralRe: the debug problem in VC++ Pin
David Crow30-Mar-08 2:54
David Crow30-Mar-08 2:54 
GeneralRe: the debug problem in VC++ Pin
Hamid_RT7-Apr-08 2:29
Hamid_RT7-Apr-08 2:29 
GeneralCustom C++ Runtime Pin
Richard Andrew x6429-Mar-08 14:24
professionalRichard Andrew x6429-Mar-08 14:24 
GeneralRe: Custom C++ Runtime Pin
Mark Salsbery29-Mar-08 14:28
Mark Salsbery29-Mar-08 14:28 
GeneralRe: Custom C++ Runtime Pin
Randor 29-Mar-08 19:25
professional Randor 29-Mar-08 19:25 
GeneralRe: Custom C++ Runtime Pin
Hamid_RT7-Apr-08 2:30
Hamid_RT7-Apr-08 2:30 
GeneralRegisterWindowClass and resources from a DLL Pin
Moak29-Mar-08 13:19
Moak29-Mar-08 13:19 
GeneralRe: RegisterWindowClass and resources from a DLL Pin
Mark Salsbery29-Mar-08 14:57
Mark Salsbery29-Mar-08 14:57 
GeneralRe: RegisterWindowClass and resources from a DLL Pin
Moak29-Mar-08 15:20
Moak29-Mar-08 15:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.