gpt4 book ai didi

c++ - list test() 和 list test 区别?

转载 作者:行者123 更新时间:2023-11-27 23:21:15 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Error on calling default constructor with empty set of brackets
What's the differences between Test t; and Test t();? if Test is a class

这段代码有什么区别,第一个编译第二个不编译。我是 C++ 的新手。

第一个样本

list<string> str;
list<string>::iterator it;

it = str.begin();

第二个样本

list<string> str();
list<string>::iterator it;

it = str.begin();

我认为在没有 parantethiss 的情况下调用默认构造函数 witch 与 () 变体相同。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com