Skip to content

Commit

Permalink
refactor: 使用 fopen 而非 open_file
Browse files Browse the repository at this point in the history
  • Loading branch information
FeignClaims authored Sep 23, 2024
1 parent 97e7275 commit e6ea315
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions faq/rule_of_350/main.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,15 @@ rule of 3/5/0: 要么不定义任何特殊函数, 要么定义它们全部
.. code-block:: cpp
:linenos:
#include <cstdio>
class Widget {
public:
Widget(std::string const& file_path) : file_(open_file(file_path)) {}
// ↓ 以只读形式打开文件, 需要之后用 fclose 释放
Widget(char const* file_path) : file_(fopen(file_path, "r")) {}
private:
file* file_;
FILE* file_;
};
int main() {
Expand Down

0 comments on commit e6ea315

Please sign in to comment.