zoukankan      html  css  js  c++  java
  • 不要出现仅靠大小写区分的相似的标识符

    程序中不要出现仅靠大小写区分的相似的标识符。

    例如: int x, X; // 变量 x 与 X 容易混淆 void foo(int x); // 函数 foo 与 FOO 容易混淆 void FOO(float x);

     1 #include <iostream>
     2 
     3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
     4 using namespace std;
     5 //定义rect类
     6 class rect {
     7     int length;
     8     int width;
     9     int area;
    10 public:
    11     rect(int l=1,int w=1)
    12     {
    13         length=l;
    14         width=w;
    15         area=length*width;
    16     }
    17     void show_rect(char *name)
    18     { 
    19         cout<<name<<":"<<endl;
    20         cout<<"length="<<length<<endl;
    21         cout<<"width="<<width<<endl;
    22         cout<<"area="<<area<<endl;
    23     }
    24 };
    25 
    26 int main(int argc, char** argv) {
    27         //用rect类创建对象
    28     rect a;
    29     rect b(2);
    30     rect c(2,3);
    31 
    32     //调用对象的函数显示对象中的数据
    33     a.show_rect("a");
    34     b.show_rect("b(2)");
    35     c.show_rect("c(2,3)");
    36     return 0;
    37 }
  • 相关阅读:
    二叉排序树
    堆排序
    线索化二叉树
    vue 格式化代码
    线程的理解
    声明式的服务调用 Feign
    使用锁 的理解
    zookeeper 的理解
    AQS 源码解析
    HashMap 的理解与结构
  • 原文地址:https://www.cnblogs.com/borter/p/9413400.html
Copyright © 2011-2022 走看看