zoukankan      html  css  js  c++  java
  • ‘,’之后要留空格,如 Function(x, y, z)

    ‘,’之后要留空格,如 Function(x, y, z)。如果‘;’不是一行的结束 符号,其后要留空格,如 for (initialization; condition; update)。

     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 //声明全局变量并初始化
     6 extern int a[]={1,2,3};
     7 extern float p=3.14;
     8 
     9 //在show()函数中使用外部变量
    10 show()  {
    11     int i;
    12     cout<<"In show():"<<endl;
    13     cout<<"p="<<p<<endl;
    14     cout<<"a[]: ";
    15     for (i=0;i<=2;i++) 
    16         cout<<a[i]<<"  ";
    17     cout<<endl;
    18     //cout<<"y="<<y<<endl; 编译出错!
    19 }
    20 
    21 //声明外部变量并初始化
    22 int y=5678;
    23 
    24 int main(int argc, char** argv) {
    25     
    26         //声明局部变量
    27     int i,p=100;
    28 
    29     //显示重名变量
    30     cout<<"In main():"<<endl;
    31     cout<<"p="<<p<<endl;
    32 
    33     //显示全局变量
    34     cout<<"::p="<<::p<<endl;
    35     cout<<"a[]: ";
    36     for (i=0;i<=2;i++)
    37         cout<<a[i]<<"  ";
    38     cout<<endl;
    39     cout<<"y="<<y<<endl;   //编译正确!
    40 
    41     show();  //调用函数
    42     return 0;
    43 }
  • 相关阅读:
    Unity中溶解shader的总结
    Unity Shader 知识点总结(二)
    Unity Shader 知识点总结(一)
    Unity优化之GC——合理优化Unity的GC
    nuxt中使用vant框架
    Redux第一节
    React动画库
    react一写工具
    几种下载第三方的方式有何不同
    React生命周期函数
  • 原文地址:https://www.cnblogs.com/borter/p/9413183.html
Copyright © 2011-2022 走看看