Ray's playground

 

2011年4月2日

Item 35: Consider alternatives to virtual functions(Effective C++)

摘要: The fundamental advice of this Item is to consider alternatives to virtual functions when searching for a design for the problem you're trying to solve. Here's a quick recap the alternatives we examined: Use the non-virtual interface idiom (NVI idiom), a form of the Template Method design pa 阅读全文

posted @ 2011-04-02 23:38 Ray Z 阅读(262) 评论(0) 推荐(0) 编辑

Debuggers and Debugger Design(Chapter 2 of Gray Hat Python)

摘要: The ability to halt a process that is being debugged is achieved by settingbreakpoints. By halting the process, you are able to inspect variables, stackarguments, and memory locations without the process changing any of theirvalues before you can record them. Breakpoints are most definitely the mos. 阅读全文

posted @ 2011-04-02 20:57 Ray Z 阅读(147) 评论(0) 推荐(0) 编辑

Setting Up Your Development Environment(Chapter 1 of Gray Hat Python)

摘要: 1>>>fromctypesimport*2>>>c_int()3c_long(0)4>>>c_char_p("helloworld!")5c_char_p('helloworld!')6>>>c_ushort(-5)7c_ushort(65531)8>>>seitz=c_char_p("lovespython")9>>>printseitz10c_char_p('lovespython')11>>> 阅读全文

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

Item 34: Differentiate between inheritance of interface and inheritance of implementation(Effective C++)

摘要: Inheritance of interface is different from inheritance of implementation. Under public inheritance, derived classes always inherit base class interfaces. Pure virtual functions specify inheritance of interface only. Simple (impure) virtual functions specify inheritance of interface plus inheritance. 阅读全文

posted @ 2011-04-02 16:42 Ray Z 阅读(357) 评论(0) 推荐(0) 编辑

View Swapping(Chapter 29 of Cocoa Programming for Mac OS X)

摘要: 1#import"MyDocument.h"2#import"DepartmentViewController.h"3#import"EmployeeViewController.h"45@implementationMyDocument67-(id)init8{9[superinit];10viewControllers=[[NSMutableArrayalloc]init];1112ManagingViewController*vc=[[DepartmentViewControlleralloc]init];13[vcsetMan 阅读全文

posted @ 2011-04-02 14:32 Ray Z 阅读(290) 评论(0) 推荐(0) 编辑

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) 编辑

导航