검색결과 리스트
C++에 해당되는 글 11건
- 2011.08.17 함수 오버로딩
글
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;
}
RECENT COMMENT