C++基础

1 函数默认参数

#include <iostream>
using namespace std;
//函数声明的时候附加默认参数
void Show(int a ,int b , int c = 2, int d = 3);
int main()
{
    Show(100,200);
    int arr[10] = {0,1,2,3,4,5,6,7,8,9};
}
//不能再函数实现中加参数,如果函数声明中已存在则重复定义,如果没有则格式错误
void Show(int a  ,int b , int c  , int d )
{
    cout << a << " " << b <<endl;
    cout << c << " " << d <<endl;
}

2 For循环

for(auto i : arr)//auto可自动识别arr中类型
 {
     cout<< i << " ";
 }
原文地址:https://www.cnblogs.com/TheQi/p/9105022.html