• C++学习笔记5:如何给变量及函数命名?


    1.遵循C++规定的变量及函数命名方法;

    2.原则:简单,易于理解;

    以下是一些例子,可以作为参考:

    //bad examples:
    int ccount;//Nobody knows what a ccount is.
    int i;//Generally bad unless use is trivial or temporary, such as loop variables.
    int _count;//don't start variable names with underscore.
    int data;//What kind of data?
    int value1,value2;//Can be hard to differentiate between the two?
    int x,y;//generally bad unless use is trivial, such as in trivial mathematical functions.
    
    //good examples:
    int customerCount;//clear what we're counting
    int index;//okay if obvious what we're indexing
    int totalScore;//good descriptive
    int numberOfApples;//descriptive
    int monstersKilled;//descriptive
    怕什么真理无穷,进一寸有一寸的欢喜。---胡适
  • 相关阅读:
    HTTP状态码
    python 连接 MySQL 数据库
    JS事件基础和绑定
    7月13号:2D的转换和过渡,动画效果设置
    JS事件流
    7月14日:JS的基础语法
    JS对表单的操作
    7月16日:DOM总结
    DOM样式表
    7月9号
  • 原文地址:https://www.cnblogs.com/hujianglang/p/6127551.html
Copyright © 2020-2023  润新知