#include "stdafx.h"
#include <iostream>
#include <vector>
using namespace std;
void func( int *p )
{
printf( "%d\n", *p );
}
int _tmain(int argc, _TCHAR* argv[/url])
{
vector<int> vi;
int i;
for( i=0; i<10; i++ )
vi.push_back(i);
vector<int>::iterator p = vi.begin();
while( p != vi.end() ) {
func(p); // ここがエラー
p++;
}
return 0;
}
上記のように書いたのですが VC++2008 Express にてコンパイルエラーerror C2664: 'func' : 1 番目の引数を 'std::_Vector_iterator<_Ty,_Alloc>' から 'int *' に変換できません。(新しい機能 ; ヘルプを参照)
with
[
_Ty=int,
_Alloc=std::allocator<int>
]
この変換を実行可能なユーザー定義変換演算子がないか、または演算子を呼び出せません。
とでます
VC++6.0 では通るのですが
どうすればコンパイルが通るのでしょうか?