Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > compile error about auto_ptr

Reply
Thread Tools

compile error about auto_ptr

 
 
George2 George2 is offline
Senior Member
Join Date: Feb 2008
Posts: 108
 
      02-23-2008
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(115 : while compiling class template member function 'void std::vector<_Ty>::_Insert_n(std::_Vector_const_ite rator<_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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
explicit auto_ptr<T>::auto_ptr(T*) ? Sousuke C++ 9 03-16-2010 11:54 AM
auto_ptr assignment compile error George2 C++ 0 03-30-2008 10:52 AM
auto_ptr compile error George2 C++ 0 03-21-2008 03:00 AM
cant compile on linux system.cant compile on cant compile onlinux system. Nagaraj C++ 1 03-01-2007 11:18 AM
auto_ptr<Derived> to auto_ptr<Base> Siemel Naran C++ 2 01-11-2005 04:45 AM



Advertisments