gpt4 book ai didi

c++ - 在 C++ 中,引用总是更好的选择吗?

转载 作者:行者123 更新时间:2023-11-28 02:35:45 26 4
gpt4 key购买 nike

<分区>

std::set<BigObject> set;
auto it = set.begin();
auto& it = set.begin();

同样,

std::string str("xxxxxxxxx");
std::string sub = str.substr(xx);
std::string& sub = str.substr(xx);

使用引用会减少调用析构函数的时间吗?为什么?

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