Ray's playground

 
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 56 下一页

2011年4月2日

System Tools(Chapter 2 of Programming Python)

摘要: 1defmore(text,numlines=15):2lines=text.splitlines()3whilelines:4chunk=lines[:numlines]5lines=lines[numlines:]6forlineinchunk:7printline8iflinesandraw_input('More?')notin['y','Y']:9break1011if__name__=='__main__':12importsys13more(open(sys.argv[1]).read(),10)14 1>&g 阅读全文

posted @ 2011-04-02 11:36 Ray Z 阅读(230) 评论(0) 推荐(0) 编辑

Item 33: Avoid hiding inherited names(Effective C++)

摘要: Names in derived classes hide names in base classes. Under public inheritance, this is never desirable. To make hidden names visible again, employ using declarations or forwarding functions.1#include<iostream>2usingnamespacestd;34classBase5{6private:7intx;89public:10virtualvoidmf1()=0;11virtua 阅读全文

posted @ 2011-04-02 09:50 Ray Z 阅读(195) 评论(0) 推荐(0) 编辑

Item 32: Make sure public inheritance models "is-a."(Effective C++)

摘要: Public inheritance means "is-a." Everything that applies to base classes must also apply to derived classes, because every derived class object is a base class object. 阅读全文

posted @ 2011-04-02 00:25 Ray Z 阅读(170) 评论(0) 推荐(0) 编辑

2011年4月1日

Hello world for tornado

摘要: 1importtornado.ioloop2importtornado.web34classMainHandler(tornado.web.RequestHandler):5defget(self):6self.write("helloworld")78application=tornado.web.Application([(r"/",MainHandler),])910if__name__=="__main__":11application.listen(8888)12tornado.ioloop.IOLoop.instance( 阅读全文

posted @ 2011-04-01 12:16 Ray Z 阅读(339) 评论(2) 推荐(0) 编辑

2011年3月31日

Item31: Minimize compilation dependencies between files.(Effective C++)

摘要: The general idea behind minimizing compilation dependencies is to depend on declarations instead of definitions. Two approaches based on this idea are Handle classes and Interface classes. Library header files should exist in full and declaration-only forms. This applies regardless of whether templ. 阅读全文

posted @ 2011-03-31 23:52 Ray Z 阅读(208) 评论(0) 推荐(0) 编辑

Item 30: Understand the ins and outs of inlining.(Effective C++)

摘要: Limit most inlining to small, frequently called functions. This facilitates debugging and binary upgradability, minimizes potential code bloat, and maximizes the chances of greater program speed. Don't declare function templates inline just because they appear in header files. 阅读全文

posted @ 2011-03-31 14:11 Ray Z 阅读(180) 评论(0) 推荐(0) 编辑

2011年3月30日

Item29: Strive for exception-safe code.(Effective C++)

摘要: Exception-safe functions leak no resources and allow no data structures to become corrupted, even when exceptions are thrown. Such functions offer the basic, strong, or nothrow guarantees. The strong guarantee can often be implemented via copy-and-swap, but the strong guarantee is not practical for. 阅读全文

posted @ 2011-03-30 23:33 Ray Z 阅读(291) 评论(0) 推荐(0) 编辑

Item 28: Avoid returning "handles" to object internals.(Effective C++)

摘要: Avoid returning handles (references, pointers, or iterators) to object internals. It increases encapsulation, helps const member functions act const, and minimizes the creation of dangling handles. 阅读全文

posted @ 2011-03-30 12:01 Ray Z 阅读(171) 评论(0) 推荐(0) 编辑

Item 27: Minimize casting.(Effective C++)

摘要: Avoid casts whenever practical, especially dynamic_casts in performance-sensitive code. If a design requires casting, try to develop a cast-free alternative. When casting is necessary, try to hide it inside a function. Clients can then call the function instead of putting casts in their own code. P. 阅读全文

posted @ 2011-03-30 11:36 Ray Z 阅读(184) 评论(0) 推荐(0) 编辑

2011年3月29日

Item 26: Postpone variable definitions as long as possible.(Effective C++)

摘要: Postpone variable definitions as long as possible. It increases program clarity and improves program efficiency. 阅读全文

posted @ 2011-03-29 10:58 Ray Z 阅读(260) 评论(0) 推荐(0) 编辑

上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 56 下一页

导航