HelloElfLoader { class Loader { std::ifstream fileStream_; public: Loader(const std::string& path); Loader(std::ifstream&& fileStream); void execute(); }; }
¹¹Ô캯ÊýÈçÏÂ, Ò²¾ÍÊDZê×¼µÄc++´ò¿ªÎļþµÄ´úÂë
HelloElfLoader.cpp:
Loader::Loader(const std::string& path) : Loader(std::ifstream(path, std::ios::in | std::ios::binary)) {} Loader::Loader(std::ifstream&& fileStream) : fileStream_(std::move(fileStream)) { if (!fileStream_) { throw std::runtime_error("open file failed"); } }
½ÓÏÂÀ´½«ÊµÏÖÉÏÃæËù˵µÄ²½Öè, Ê×ÏÈÊǽâÎöELFÎļþ
¡¡