大家好,又见面了,我是你们的朋友全栈君。
1. 一维
vector<int> obj(size);
或
vector<int> obj;
obj.resize(size);
2. 二维
vector<vector<int> > obj(rsize, vector<int>(lsize, 0));
或
vector<vector<int>> obj;
obj.resize(rsize);
for(int i = 0; i < rsize; i++)
obj[i].resize(lsize);
.当调用vector<int> obj(size)时,调用构造函数 :
explicit vector(_CRT_GUARDOVERFLOW const size_type _Count, const _Alloc& _Al = _Alloc())
: _Mypair(_One_then_variadic_args_t(), _Al) { // construct from _Count * _Ty(), optional allocator
_Construct_n_copies_of_ty(_Count, _Value_init_tag{});
}
.当调用vector<int> obj(size, 0)的时候,调用构造函数:
vector(_CRT_GUARDOVERFLOW const size_type _Count, const _Ty& _Val, const _Alloc& _Al = _Alloc())
: _Mypair(_One_then_variadic_args_t(), _Al) { // construct from _Count * _Val, optional allocator
_Construct_n_copies_of_ty(_Count, _Val);
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/192370.html原文链接:https://javaforall.cn