C++ GuildeLines

王朝c/c++·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

If a class needs a custom copy constructor, copy

assignment operator, or destructor, it probably needs all three.Avoid hard-wiring information that needlessly makes

code more brittle and limits flexibility.Always make all data members private. The only exception

is the case of a C-style struct which isn't intended to

encapsulate anything and where all members are public.

Write (only) useful comments. Never write comments that

repeat the code; instead, write comments that explain the code and the reasons

why you wrote it that way.

Practice const-correctnessAvoid type switching; prefer type safetyNever use "underhanded names"—ones that

begin with an underscore or that contain a double underscore. They are reserved

for your compiler and standard library implementation.If you want to represent variant types, for now prefer

to use boost::any

(or something equally simple).

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航