我在std::vector课堂上遇到了问题,我创建了一个struct
struct Triplet{
int first;
int second;
int third;
};
Run Code Online (Sandbox Code Playgroud)
我创建了一个vector<Triplet> T. 我的问题是它不会包含我需要的元素,即使T.max_size() = 357913941我只得到 T.size() = 60540697或 T.size() = 40360465使用该函数
vector<Triplet> T;
while(true)
{
Triplet t;
t.first = 1; t.second = 1 ; t.third = 1;
try {
T.push_back(t);
} catch (...) {
break;
}
}
qDebug() << T.size();
Run Code Online (Sandbox Code Playgroud)
谁能解释一下为什么要这样做?我在 Windows 10 和 16Go 的 RAM 上运行,使用 Qt 和 VSC++ 2017 x86(由于我无法为 x64 编译的 Lemon 库),