05 2022 档案

摘要:返回值优化(return value optimization, RVO)是一种减少开销的行为 下面一段代码定义了一个结构体,用于显示返回值优化的效果 static int counter; // counter to identify instances of S struct S { int i 阅读全文
posted @ 2022-05-31 16:54 yuzuki_n 阅读(238) 评论(0) 推荐(0) 编辑
摘要:知识点非常简单,直接看代码 struct Person { int age; std::string name; }; int main() { std::vector<Person> v{{10, "Tom"}, {20, "lily"}}; for (const auto &[age, name 阅读全文
posted @ 2022-05-31 12:08 yuzuki_n 阅读(50) 评论(0) 推荐(0) 编辑
摘要:1 内存泄漏 int *arr = new int[5]; // 忘记释放内存,又申请了一块新的内存 arr = new int[10]; 2 指针指向无效的内存单元 bool *a, *b; a = new bool; b = a; delete a; // 指向的内存已经被释放了 delete 阅读全文
posted @ 2022-05-01 14:03 yuzuki_n 阅读(16) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示