代码示例:(标识:652b673d87e2f)
#include <iostream>
using namespace std;
 
int sum(int a, int b=20){
    int result;
    result = a + b;
    return (result);
}

int main (){
    // 局部变量声明
    int a = 100;
    int b = 200;
    int result;
    // 调用函数来添加值
    result = sum(a, b);
    cout << "Total value is :" << result << endl;     // 再次调用函数
    result = sum(a); 
    cout << "Total value is :" << result << endl;
    return 0;
} 
运行结果: