052.函数-函数常见样式

#include <iostream>
using namespace std;

//函数常见样式
//1.无参无返
void test01()
{
    cout << "test01" << endl;
}

//2.有参无返
void test02(int a)
{
    cout << "test02" << a << endl;
}

//3.无参有返
int test03()
{
    cout << "test03" << endl;
    return 100;
}

//4.有参有返
int test04(int a)
{
    cout << "test04" << endl;
    return a;
}

int main()
{
    //1.无参无返
    test01();

    //2.有参无返
    test02(2);

    //3.无参有返
    int a = test03();

    //4.有参有返
    int b = 1000;
    int c = test04(b);

    system("pause");
    return 0;
}

 

posted @ 2021-09-04 13:43  梦之心  阅读(29)  评论(0编辑  收藏  举报