zoukankan      html  css  js  c++  java
  • 变量和参数用小写字母开头的单词组合而成

    变量和参数用小写字母开头的单词组合而成。 例如: BOOL flag; int drawMode;

     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 class ex_class {
     6     int value;
     7 public:
     8     ex_class(int n) {
     9         value=n;
    10         cout << "Stack initialized." << endl;
    11     }
    12     ~ex_class() {    
    13         cout << "The Object destroyed." <<endl;  
    14     }
    15     void set_value(int n);
    16     void show_val(char *name);
    17 } ;
    18 
    19 //在类外定义内联成员函数
    20 inline void ex_class::set_value(int n) {
    21     value=n;
    22 }
    23 //在类外定义非内联成员函数
    24 void ex_class::show_val(char *name) {
    25     cout<<name<<": ";
    26     cout<<value<<endl;
    27 }
    28 //在main()函数中测试ex_class类
    29 int main(int argc, char** argv) {
    30         //创建对象x和y
    31     ex_class x(100),y(200);
    32 
    33     //显示对象的数据
    34     x.show_val("x");
    35     y.show_val("y");
    36 
    37     //设置新值给对象
    38     x.set_value(1);
    39     y.set_value(2);
    40 
    41     //显示对象的数据
    42     x.show_val("x");
    43     y.show_val("y");
    44 
    45     return 0;
    46     return 0;
    47 }
  • 相关阅读:
    day02-数据库操作
    day01-MySQL介绍
    3-socketserver
    1-多线程与多进程
    keyword模块
    math模块
    查看进程pid与ppid
    开启进程的两种方式
    进程理论
    进程
  • 原文地址:https://www.cnblogs.com/borter/p/9413429.html
Copyright © 2011-2022 走看看