int function (int n) {}
    int function (char n) {}
    int function (int n, char n) {}


※디폴트 매개변수 → 전달되지않은 인자를 대신하기 위해, 기본값이 설정되어있는 변수.
  
   int function ( int a=0) { return a+1;}


※사용법

#include < iostream>
using namespace std;

int BoxVolume(int lenght, int width=1, int height=1);
int main()
{
  cout<<"[3,3,3]:" <<BoxVolume(3,3,3) <<endl;
  cout<<"[5,5,def]:"<<BoxVolume(5,5) <<endl;
  cout<<"[7,def,def]:"<<BoxVolume(7) <<endl;
}

int BoxVolume (int lenght, width=1, int height=1)
{
   return length*width*height;
}

'C++ > 열혈강의C++' 카테고리의 다른 글

Const  (0) 2011.08.23
NameSpace  (0) 2011.08.17
인라인 함수  (0) 2011.08.17
매크로 함수  (0) 2011.08.17