Hi,
I am working in migration project from VC6 to VC9. In VC9 (Visual Studio 2008), I got compilation error while passing const member to a method which is accepting reference. It is getting compiled without error in VC6.
Sample Program:
class A
{
};
typedef CList<A, A&> CAlist;
class B
{
CAlist m_Alist;
public:
const B& operator=( const B& Src);
};
const B& B::operator=( const B& Src)
{
POSITION pos = Src.m_Alist.GetHeadPosition();
while( pos != NULL)
{
**m_Alist.AddTail( Src.m_Alist.GetNext(pos) );**
}
return *this;
}
Error: Whiling compiling above program, I got error as
error C2664: 'POSITION CList::AddTail(ARG_TYPE)' : cannot convert parameter 1 from 'const A' to 'A &'
Please help me to resolve this error.