C++入门4——函数

2017-03-20  本文已影响0人  hello2333

函数声明

#include <iostream>

using namespace std;

void f(int a);

int main(){
    f(3);
    //f(4);
}

void f(int a){
    //static int n = 0;
    while(a --){
        static int n = 0;
        int x = 0;
        cout << "n == " << n ++ << " x == " << x ++ << endl;
    }
}

输出为:
n == 0 x == 0
n == 1 x == 0
n == 2 x == 0

参数传递

返回值

上一篇 下一篇

猜你喜欢

热点阅读