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

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

     1 #include <iostream>
     2 #include <stdlib.h>
     3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
     4 
     5 using namespace std;
     6 //定义timer类
     7 class timer{
     8     long minutes;
     9 public:
    10     //无参数构造函数
    11     timer(void) { 
    12         minutes =0;
    13     };
    14     //字符指针参数的构造函数
    15     timer(char *m) { 
    16         minutes = atoi(m);
    17     };
    18     //整数类型的构造函数
    19     timer(int h, int m) { 
    20         minutes = 60*h+m ;
    21     };
    22     //双精度浮点型构造函数
    23     timer(double h) { 
    24         minutes = (int) 60*h ;
    25     };
    26     long getminutes(void) { return minutes ; };
    27 };
    28 
    29 int main(int argc, char** argv) {
    30         //使用double类型的构造函数创建对象
    31     timer start(8.30),finish(17.30);
    32     cout<<"finish(17.30)-start(8.30)=";
    33     cout<<finish.getminutes()-start.getminutes()<<endl;  
    34 
    35     //使用char指针类型的构造函数创建对象
    36     timer start0("500"),finish0("800");   //创建对象
    37     cout<<"finish0("800")-start0("500")=";
    38     cout<<finish0.getminutes()-start0.getminutes()<<endl;  
    39 
    40     //使用无参数构造函数和整型构造函数创建对象
    41     timer start1;   
    42     timer finish1(3,30);  
    43     cout<<"finish1(3,30)-start1=";
    44     cout<<finish1.getminutes()-start1.getminutes()<<endl;  
    45 
    46     return 0;
    47 }
  • 相关阅读:
    char*,const char*和string的相互转换[转]
    1.0到2.0 的变化
    Hello项目分析
    VS上编译Lua5.1.4生成静态库
    cocos2dx 自带动画
    asp.net2.0安全性(Login系列控件)
    用js实现的对css的一些操作方法
    mapxtreme开发小结3(c#)
    asp.net页面事件执行顺序
    access与SqlServer 之时间与日期及其它SQL语句比较
  • 原文地址:https://www.cnblogs.com/borter/p/9413397.html
Copyright © 2011-2022 走看看