Skip to content

Commit

Permalink
refactor: 使用 fclose 而非 close_file
Browse files Browse the repository at this point in the history
  • Loading branch information
FeignClaims committed Sep 23, 2024
1 parent 2a7c924 commit e834521
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions faq/rule_of_350/main.rst
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ rule of 3/5: 定义全部特殊函数
class Widget {
public:
Widget(char const* file_path) : file_(fopen(file_path, "r")) {}
~Widget() { close_file(file_); }
~Widget() { fclose(file_); }
private:
FILE* file_;
Expand All @@ -281,7 +281,7 @@ rule of 3/5: 定义全部特殊函数
int main() {
Widget a("text.txt");
Widget b(a); // 拷贝后, a、b 均占有 "text.txt" 文件资源
} // 错误: a、b 析构时均调用 close_file, 因而关闭文件两次!
} // 错误: a、b 析构时均调用 fclose, 因而关闭文件两次!
.. tab:: 只定义拷贝函数

Expand Down

0 comments on commit e834521

Please sign in to comment.