목차
메소드 오버로딩(method overloading)
연산자 오버로딩(operator overloading)
사용자 정의 타입 변환 오버로딩
(user-defined type conversion overloading)
연산자 오버로딩(operator overloading)
사용자 정의 타입 변환 오버로딩
(user-defined type conversion overloading)
본문내용
같은 이름을 가진 method를 여러개 지정
compiler가 해당 parameter를 체크하여 그에 알맞는 method를 자동으로 호출해 주는 것
제약사항
return type만 달라서는 overloading이 될 수 없다.
parameter의 갯수나 type, 순서 서로 다르다.
string name = “홍길동”;
Console.WriteLine(name); // string type의 parameter를 받는 WriteLine method
int age = 20;
Console.WriteLine(age); // integer type의 parameter를 받는 WriteLine method
Console.WriteLine(“이름 = {0}, 나이 = {1}”, name, age);
// string 과 object type을 가변갯수 parameter로 받는 WriteLine method
int SquareInt(intx){
return x * x;
}
float SquareFloat(float x){
return x * x;
}
double SquareDouble(double x){
return x * x;
}
int Square(int x){
return x * x;
}
Floatㅁ Square(float x){
return x * x;
}
double Square(double x){
return x * x;
}
compiler가 해당 parameter를 체크하여 그에 알맞는 method를 자동으로 호출해 주는 것
제약사항
return type만 달라서는 overloading이 될 수 없다.
parameter의 갯수나 type, 순서 서로 다르다.
string name = “홍길동”;
Console.WriteLine(name); // string type의 parameter를 받는 WriteLine method
int age = 20;
Console.WriteLine(age); // integer type의 parameter를 받는 WriteLine method
Console.WriteLine(“이름 = {0}, 나이 = {1}”, name, age);
// string 과 object type을 가변갯수 parameter로 받는 WriteLine method
int SquareInt(intx){
return x * x;
}
float SquareFloat(float x){
return x * x;
}
double SquareDouble(double x){
return x * x;
}
int Square(int x){
return x * x;
}
Floatㅁ Square(float x){
return x * x;
}
double Square(double x){
return x * x;
}
추천자료
- c로배우는알고리즘에서 ROBOT프로그램을 C언어로 바꾸자.
- C언어 야구 게임
- C언어를 이용해 하노이탑 구현 프로그램
- C언어를 이용한 분수의 덧셈과 곱셈을 하는 프로그램
- C언어를 이용해 문자열을 추출하는 프로그램
- C언어를 이용한 야구게임(숫자맞추기) 프로그램
- C언어를 이용한 성적처리(성적관리) 프로그램
- C언어를 이용한 [3][3]행렬(3*3행렬), 행렬의 덧셈과 행렬의 곱셈
- C언어 처음공부하는 사람들에게 도움이 되는 코딩들(기초부터 포인터까지)
- c언어로 만든 typedef 구조체 개념 프로그램
- c언어 계산기
- c언어로 애니메이션을 만들어 주세요
- c언어에서의 포인터(pointer)
- C언어로 제작한 푸쉬푸쉬 게임