1
可能重复:
Do the parentheses after the type name make a difference with new?正在初始化智能指针
请告诉我下面的initialisations之间的区别?在教程中,它和#1一样,但是如果我使用下面的#2方法,它会产生什么影响?
struct X
{
X() {}
int x;
};
int main()
{
std::auto_ptr<X> p1(new X); // #1
std::auto_ptr<X> p2(new X()); // #2
}
看到这个很好的参考:http://stackoverflow.com/questions/620137/do-the-parentheses-after-the-type-name-make-a-difference-with-new – JRL 2012-02-05 02:36:36