不太懂啊。。。
参考博文:
https://blog.csdn.net/lovehuishouzan/article/details/60966404
001
#ifndef MYFUNC_H
#define MYFUNC_H
//函数声明
void print(int *,int);
int sum(int ,int);
#endif
002
/*
Description: 函数声明
一个函数只能定义一次,但是可以声明多次。
函数原型:函数返回类型,函数名,形参列表
-可以省略形参名,必须有形参类型
函数在头文件中声明,在源文件中定义
-定义函数的源文件中也要包含函数声明头文件
默认实参
-既可以在函数声明中也可以在函数定义中指定默认实参
-通常是在函数声明中提供默认实参
*/
#include<iostream>
#include "myfunc.h"
using namespace std;
int sum(int a = 1,int b = 2)
{
return a + b;
}
// [Error] ld returned 1 exit status
int main()
{
int m[] = {0,1,2,3,4,5,6,7,8,9};
print(m,10);
cout<<sum()<<endl;//默认实参
return 0;
}
//函数定义
void print(int *arr,int size)
{
for(int i = 0;i != size;++i)
{
cout<<arr[i]<<" ";
}
cout<<endl;
}