对于vector的一些用法,很奇怪
string cWord[6] = { "sdf", "sdfds", "sdf", "fsdf", "fsdf", "fsdf"};
vector<string> svec(cWord, cWord+6);
vector<string>::iterator I = svec.begin()+3;
if(!(I->empty()))
{
cout << *I << endl;
}
用法是正确的,但是下面就不正确
int a[7] = {0, 1, 2, 3, 4, 5, 6};
vector<int> ivec(a, a+7);
vector<int>::iterator I = ivec.begin()+3;
if(!(I->empty()))
{
cout << *I << endl;
}
错误码是"error C2227: left of '->empty' must point to class/struct/union"
这是为什么?