compile error about auto_ptr

G

George3

Hello everyone,


I am confused to read what the compiler says. Could anyone explain what
it means?


Code:
--------------------

#include <memory>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main( )
{
int i = 0;

vector<auto_ptr<int>> vc;
for (i = 0; i < 5; i ++) // 0 1 2 3 4
{
auto_ptr<int> pi (new int(i));
vc.push_back (pi);
}

return 0;
}

--------------------


1>Compiling...
1>main.cpp
1>d:\program files\microsoft visual studio 9.0\vc\include\vector(1209)
: error C2558: class 'std::auto_ptr<_Ty>' : no copy constructor
available or copy constructor is declared 'explicit'
1> with
1> [
1> _Ty=int
1> ]
1> d:\program files\microsoft visual studio
9.0\vc\include\vector(1158) : while compiling class template member
function 'void
std::vector<_Ty>::_Insert_n(std::_Vector_const_iterator<_Ty,_Alloc>,unsigned
int,const _Ty &)'
1> with
1> [
1> _Ty=std::auto_ptr<int>,
1> _Alloc=std::allocator<std::auto_ptr<int>>
1> ]
1> d:\visual studio
2008\projects\test_autoptr1\test_autoptr1\main.cpp(11) : see reference
to class template instantiation 'std::vector<_Ty>' being compiled
1> with
1> [
1> _Ty=std::auto_ptr<int>
1> ]
1>d:\program files\microsoft visual studio 9.0\vc\include\vector(1233)
: error C2558: class 'std::auto_ptr<_Ty>' : no copy constructor
available or copy constructor is declared 'explicit'
1> with
1> [
1> _Ty=int
1> ]


thanks in advance,
George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top