E
Evgeny
Hi, all!
I try to convert my existing code written in VC6 to VC7 and have some
problem with stl auto pointer template.
class CColumn;
#include <memory>
typedef auto_ptr<CMyBase> CMyBasePtr;
class CMyBase
{
virtual CMyBase* Clone(void) const
{ return MyBasePtr(new MyBase()); }
}
class CMyTest : public MyBase
{
virtual CMyBase* Clone(void) const
{
return MyBasePtr(new CMyTest()); - this line detected as wrong and i
get compiler message C2440: 'return' : cannot convert from
'std::auto_ptr<_Ty>' to 'CMyBase*'
}
}
If i change to follow implementation a get other error C2558
class CMyBase
{
virtual CMyBasePtr Clone(void) const
{ return new MyBase());}
}
class CMyTest : public MyBase
{
virtual CMyBase* Clone(void) const
{
return MyBasePtr(new CMyTest()); - this line detected as wrong and i
get compiler message C2558: class 'std::auto_ptr<_Ty>' : no copy constructor
available or copy constructor is declared 'explicit
}
}
Where is a problem?? It's compiled fine in VC6!
Thanks in advance,
Evgeny
I try to convert my existing code written in VC6 to VC7 and have some
problem with stl auto pointer template.
class CColumn;
#include <memory>
typedef auto_ptr<CMyBase> CMyBasePtr;
class CMyBase
{
virtual CMyBase* Clone(void) const
{ return MyBasePtr(new MyBase()); }
}
class CMyTest : public MyBase
{
virtual CMyBase* Clone(void) const
{
return MyBasePtr(new CMyTest()); - this line detected as wrong and i
get compiler message C2440: 'return' : cannot convert from
'std::auto_ptr<_Ty>' to 'CMyBase*'
}
}
If i change to follow implementation a get other error C2558
class CMyBase
{
virtual CMyBasePtr Clone(void) const
{ return new MyBase());}
}
class CMyTest : public MyBase
{
virtual CMyBase* Clone(void) const
{
return MyBasePtr(new CMyTest()); - this line detected as wrong and i
get compiler message C2558: class 'std::auto_ptr<_Ty>' : no copy constructor
available or copy constructor is declared 'explicit
}
}
Where is a problem?? It's compiled fine in VC6!
Thanks in advance,
Evgeny