在使用vector<>中我有一个小问题,比如vector<string>做string的数组,可以用pash_back()输入,我想知道,怎样把指针指到任何一个已经输入的string的头???
reference front( );
const_reference front( ) const;
///////////////////////////////////
for example:
#include <vector>
#include <iostream>
int main( )
{
using namespace std;
vector <int> v1;
v1.push_back( 10 );
v1.push_back( 11 );
v1.push_back( 12 );
int& i = v1.front( );
const int& ii = v1.front( );
cout << "The first integer of v1 is "<< i << endl;
i++;
cout << "The second integer of v1 is "<< ii << endl;
}
output:
The first integer of v1 is 10
The second integer of v1 is 11