compile error about auto_ptr
- From: George <George@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 23 Feb 2008 06:11:01 -0800
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;
}
[/Code]
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
.
- Follow-Ups:
- Re: compile error about auto_ptr
- From: Alf P. Steinbach
- Re: compile error about auto_ptr
- From: Alex Blekhman
- Re: compile error about auto_ptr
- From: Abhishek Padmanabh
- Re: compile error about auto_ptr
- From: Igor Tandetnik
- Re: compile error about auto_ptr
- Prev by Date: Re: compile error about destructor
- Next by Date: Re: data breakpoint
- Previous by thread: Re: DLL function address
- Next by thread: Re: compile error about auto_ptr
- Index(es):
Relevant Pages
|