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 }
  • 相关阅读:
    C#多态的实现
    C#虚方法
    stm32HAL库中串口部分各个传输和接收函数分析
    ASC字符串取模网址
    STM32F1高级定时器做普通PWM输出配置(例TIM1)
    maven 插件说明
    mac 离线安装yarn
    Tomcat 远程调试
    杀死 tomcat 进程的脚本
    mysql 安装
  • 原文地址:https://www.cnblogs.com/borter/p/9413183.html
Copyright © 2011-2022 走看看