<分区>
这是我的功能:
const vector<int>& getVInt(){
vector<int> vint;
(...)
return vint;
}
还有,
vector<int> x = getVInt();
返回:
terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check
和
const vector<int>& x = getVInt();
不返回任何内容(大小不同于 0 但在我使用 x.at(i) 时没有值的 vector )。
我在论坛中查找过,但有关 temporary 和 const ref 的答案无法帮助我理解。
谢谢。