C++学习第三十五篇

/*
* 函数的常见样式
* 1、无参无返
* 2、有参无返
* 3、无参有返
* 4、有参有返
*/
#include<iostream>
using namespace std;

//1、无参无返
void test01()
{
	//void a = 10;//无类型不可以创建变量 ,原因是无法分配内存
	cout << "this is teat01" << endl;
	//test01();函数调用
}
//2、有参无返
void test02(int a)
{
	cout << "this is test02" << endl;
	cout << "a = " << a << endl;
}
//3、无参有返
int test03()
{
	cout << "this is test03" << endl;
	return 10;
}
//4、有参有返
int test04(int a,int b)
{
	cout << "this is test04" << endl;
	int sum = a + b;
	return sum;
}

int main()
{
	test01();
	test02(10);
	test03();
	test04(10,20);
	system("pause");
	return 0;
}

			    

猜你喜欢

转载自blog.csdn.net/weixin_47358937/article/details/121534776
今日推荐