学习日志—类型和声明—advice

[1]Keep scopes small.

 

[2]Don't use the same name in both a scope and  an enclosing  scope.

 

[3]Declare one name (only) per declaration.

 

[4]Keep common and local names short, and uncommon and nolocal names longer;

 

[5]Avoid similar-looking names;

 

[6]Maintain a consistent naming style;

 

[7]Choose names carefully to reflect meaning rather than implementation;

 

[8]Use a typedef to define a meaningful  name for a built-in type in case in which the built-in type used to represent a value might change;

 

[9]Remember that every declaration must specify a type (there is no "implicit int";

 

[10]Avoid unnecessary assumptions about the numeric value of characters;

 

[11]Avoid unnecessary assumptions about the size of integers;

 

[12]Avoid unnucessary assumptions about the range of floating-point types;

 

[13]Perfer a plain int over a short int or long int ;

 

[14]Perfer double over a float or long double;

 

[15]Perfer plain char over signed char and unsigned char;

 

[16]Avoid making unnecessary assumptions about the sizes of objects;

 

[17]Avoid unsigned arithmetic;

 

[18]View signed to unsigned and unsigned to signed conversions with suspicion;

 

[19]View floating-point to integer conversions with suspicion;

 

[20]View conversions to a smaller type,such as int to char ,with suspicion;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值