C++基础学习(code)
算是突袭学习吧,可能不是很细。
英语渣,但还是可能会写一些英文注释,提高提高~~
#include <iostream>
using namespace std;
//函数声明,要么定义在main前,要么在main前面自己添加定义;
//if default parameter exist, it only be in one place.
int max(int, int=10);
int main()
{
int num1, num2;
cin >> num1 >> num2; //cin空格结束
int maxnum1 = max(num1, num2);
int maxnum2= max(num1);
cout <<"both input number:"<< maxnum1 << endl;
cout << "use default parameter:" << maxnum2 << endl;
system("pause"); //为了出现小黑框
return 0;
}
//函数传值三种情况:值传递,指针传递,引用传递
int max(int num1, int num2)
{
return num1 > num2 ? num1 : num2;
}