Hwan'Story › @kim-hwan

4. 디폴트 매개 변수

· (수정 ) · 조회 83

4. 디폴트 매개 변수

소스코드

#include <iostream>

int function(int a=0)
{
  return a+1;
}

int main(void)
{
  std::cout<<"function() call :"<<function()<<std::endl;
  std::cout<<"function(5) call :"<<function(5)<<std::endl;

  return 0;
}

디폴트 매개 변수와, 함수의 오버로딩을 동시에 정의할때 조심.

실행결과

image.png

관련 게시글