|
#include <vector>
#include <iostream>
using namespace std;
bool is_equal( const int *ia, int ia_size, const vector<int> ivec )
{
if ( ia_size != ivec.size() )
return false;
for( vector<int>::iterator it = ivec.begin(); it != ivec.end(); ++it ){
if ( *ia != *it )
return false;
else{
++ia;
++it;
}
}
return true;
}
int main()
{
const int size = 4;
int a[size]={0,1,2,3};
const vector<int> b( a, a+6 );
if(is_equal( a, size, b ))
cout << "equle\n";
else
cout << "donot equle\n";
}
编译生成的错误为:
equal.cc: In function 'bool is_equal(const int*, int, std::vector<int, std::allocator<int> >)':
equal.cc:8: error: conversion from '__gnu_cxx::__normal_iterator<const int*, std::vector<int, std::allocator<int> > >' to non-scalar type '__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >' requested |
|