函数的常见样式

#inclue<iosteam>
using namespace std;

//函数常见样式
// 1、无参无返回值
void test01(){
  cout<<"this is test01" << endl;
}

// 2 、有参无返回值
void test02(int a){
  cout << "this is  test02 a =" << a <<endl;
}

// 无参数有返回值
int (){
  cout << "this is test03"<<endl;
  return 1000;
}
//有参数有返回值

int test04 (int a){
  cout << "this is test04 a =" << a <<endl;
  retrurn 1000;
}

int main(){
  //无参无返函数调用
  test01();
  
  //有参无返回函数调用
  test02(100);

  //无参有返回值函数的调用
 int num1 = test03();
 cout << "num1" << num1 <<endl;

  //有参数有返回值的调用
  int num2 = test04(10000);
  cout << "num2 = "<< num2 <<endl;

}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容