|
@@ -0,0 +1,51 @@
|
|
|
+#include <iostream>
|
|
|
+
|
|
|
+//常见的函数样式有4种
|
|
|
+//1、无参无返
|
|
|
+void test01()
|
|
|
+{
|
|
|
+ std::cout << "This is test01" << std::endl;
|
|
|
+}
|
|
|
+//2、有参无返
|
|
|
+void test02(int a)
|
|
|
+{
|
|
|
+ std::cout << "This is test02 a = " << a << std::endl;
|
|
|
+}
|
|
|
+//3、无参有返
|
|
|
+int test03()
|
|
|
+{
|
|
|
+ std::cout << "This is test03 " << std::endl;
|
|
|
+
|
|
|
+ return 1000;
|
|
|
+}
|
|
|
+
|
|
|
+//4、有参有返
|
|
|
+int test04(int a)
|
|
|
+{
|
|
|
+ std::cout << "This is test 04 a= " << a << std::endl;
|
|
|
+
|
|
|
+ return a;
|
|
|
+}
|
|
|
+
|
|
|
+int main4()
|
|
|
+{
|
|
|
+ //无参无返的函数调用
|
|
|
+ test01();
|
|
|
+
|
|
|
+ //有参无返函数调用
|
|
|
+ test02(100);
|
|
|
+
|
|
|
+ //无参有返函数的调用
|
|
|
+ int num1 = test03();
|
|
|
+ std::cout << "num1 = " << num1 << std::endl;
|
|
|
+
|
|
|
+ //有参有返函数的调用
|
|
|
+ int num2 = test04(1000);
|
|
|
+ std::cout << "num2 =" << num2 << std::endl;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ system("pause");
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|