6.3 函数常见样式
函数一共有四种常见样式:
- 无参无返
- 有参无返
- 无参有返
- 有参有返
这四种形式定义如下:
#include<iostream>
using namespace std;
//1、无参无返
void test1()
{
cout << "this is test1." << endl;
}
//2、有参无返
void test2(int a)
{
cout << "this is test2. " << a << endl;
}
//3、无参有返
int test3()
{
cout << "this is test3." << endl;
return 1000;
}
//3、有参有返
int test4(int a)
{
cout << "this is test4. " << a << endl;
return a;
}
int main()
{
system("pause");
return 0;
}