2.5 局部变量

在函数内部声明的变量为局部变量,该变量只存活于该函数中

复制代码
#include<iostream>
void show(int);
int main(){
    int x = 1;
    show(x);
    std::cout << x << std::endl;
    return 0;
}
void show(int x){
    x = x + 1;
    std::cout << x << std::endl;
}
复制代码

 

输出结果:

2

1

posted @ 2015-05-14 13:54  cppstudy  阅读(131)  评论(0)    收藏  举报
点击右上角即可分享
微信分享提示