the address of vector

#include <vector>
#include
<iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
vector
<int> v;
v.push_back(
123456);
v.push_back(
12);

vector
<int>::iterator iter;
iter
= v.begin();
int *p = iter.operator->();
vector
<int> *pp = &v;
cout
<<"address of v:"<<pp<<endl;
cout
<<"address of first element in v:"<<p<<" and value:"<<*p<<endl;

for (int i=0; i < 1000000;++i)
{
v.push_back(i);
}

iter
= v.begin();
p
= iter.operator->();
pp
= &v;
cout
<<"address of v:"<<pp<<endl;
cout
<<"address of first element in v:"<<p<<" and value:"<<*p<<endl;

return 0;
}
posted @ 2011-05-16 10:50  嗷嗷  阅读(213)  评论(1编辑  收藏  举报