摘要:
先来看一小段代码,它取自 Bjarne Stroustrup 的演讲“Speaking C++ as a Native”:
// use an object to represent a resource ("resource acquisition is initialization")
class File_handle { // belongs in some support library
FILE* p;
public:
File_handle(const char* pp, const char* r)
{ p = fopen(pp,r); if (p==0) throw Cannot_open(pp); }
File_handle(const string& s, const char* r)
{ p = fopen(s.c_str(),r); if (p==0) throw Cannot_open(pp); }
~F 阅读全文
posted @ 2005-11-09 19:58 Scott.YU 阅读(1924) 评论(0) 推荐(0) 编辑