A
Andrew Ward
The following program compiles and runs fine on my compiler (vc7.1):
#include <memory>
using namespace std;
class X {};
auto_ptr<X> foo()
{
return auto_ptr<X>(new X());
}
int main()
{
auto_ptr<X> x;
x = foo();
}
However running it through lint I get the following error:
x = foo();
main.cpp(15) : Error 1058: Initializing a non-const reference
'std::auto_ptr<X>
&' with a non-lvalue
As this is a lint error, not a warning, I would not have thought it
would compile, should it have? Could someone explain the error to me?
Thanks.
#include <memory>
using namespace std;
class X {};
auto_ptr<X> foo()
{
return auto_ptr<X>(new X());
}
int main()
{
auto_ptr<X> x;
x = foo();
}
However running it through lint I get the following error:
x = foo();
main.cpp(15) : Error 1058: Initializing a non-const reference
'std::auto_ptr<X>
&' with a non-lvalue
As this is a lint error, not a warning, I would not have thought it
would compile, should it have? Could someone explain the error to me?
Thanks.