explicit vector ( size_type n, const T& value= T(), const Allocator& = Allocator() );
vector<int> vec(10);
cout << "vec.size: " << vec.size() << endl;
for (vector<int>::const_iterator iter=vec.begin(); iter != vec.end(); ++iter)
{
cout << *iter << endl;
}
Run Code Online (Sandbox Code Playgroud)
VS2010的输出:
vec.size: 10
0
0
0
0
0
0
0
0
0
0
Run Code Online (Sandbox Code Playgroud)
问题>:基于最新的C++标准,当我们使用vectorObject(size_type)定义向量对象时,默认的int值是多少?
在这里您可以看到,VS2010输出0作为默认的int值.但我不知道这是否是C++标准所要求的.
| 归档时间: |
|
| 查看次数: |
347 次 |
| 最近记录: |