compile error about auto_ptr
- From: George3 <George3.358l1n@xxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 23 Feb 2008 08:10:46 -0600
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
--
George3
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------
.
- Follow-Ups:
- Re: compile error about auto_ptr
- From: SvenC
- Re: compile error about auto_ptr
- Prev by Date: change const property through overloading
- Next by Date: Re: Calling a managed function from native code
- Previous by thread: change const property through overloading
- Next by thread: Re: compile error about auto_ptr
- Index(es):
Relevant Pages
|