【发布时间】:2012-03-03 19:37:17
【问题描述】:
可能重复:
Do the parentheses after the type name make a difference with new?
What do the following phrases mean in C++: zero-, default- and value-initialization?
我使用矢量没有任何问题,但我仍然对此有疑问。 我总是使用这样的代码,
vector<int>* v1 = new vector<int>;
那么,我可以使用:
vector<int>* v2 = new vector<int>();
我知道 () 做什么,但有什么区别?在 v1 中,向量是否曾经初始化任何整数?
【问题讨论】:
-
你为什么使用
new?vector<int> v1;怎么了?
标签: c++ initialization