Ray's playground

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

2011年4月4日

Item 39: Use private inheritance judiciously(Effective C++)

摘要: Private inheritance means is-implemented-in-terms of. It's usually inferior to composition, but it makes sense when a derived class needs access to protected base class members or needs to redefine inherited virtual functions. Unlike composition, private inheritance can enable the empty base opt 阅读全文

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

Item 38: Model "has-a" or "is-implemented-in-terms-of" through composition(Effective C++)

摘要: Composition has meanings completely different from that of public inheritance. In the application domain, composition means has-a. In the implementation domain, it means is-implemented-in-terms-of. 阅读全文

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

2011年4月3日

char array

摘要: 1#include<iostream>2#include<vector>3#include<string>4usingnamespacestd;56intmain()7{8constchar*p="hello";9intcount=0;10while(*p)11{12cout<<*p<<endl;13count++;14p++;15}1617constcharca[]={'h','e','l','l','o'};18constchar* 阅读全文

posted @ 2011-04-03 11:18 Ray Z 阅读(444) 评论(0) 推荐(0) 编辑

Item 37: Never redefine a function's inherited default parameter value(Effective C++)

摘要: Never redefine an inherited default parameter value, because default parameter values are statically bound, while virtual functions — the only functions you should be overriding — are dynamically bound.1#include<iostream>2#include<string>3usingnamespacestd;45classShape6{7public:8virtualv 阅读全文

posted @ 2011-04-03 11:09 Ray Z 阅读(303) 评论(0) 推荐(0) 编辑

Item 36: Never redefine an inherited non-virtual function(Effective C++)

摘要: Never redefine an inherited non-virtual function. 阅读全文

posted @ 2011-04-03 10:51 Ray Z 阅读(103) 评论(0) 推荐(0) 编辑

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

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

导航