U E D R , A S I H C RSS

Java Study2003/세번째수업

오버로딩(Overloading) 및 리팩토링


  • 오버로딩 - C++에서 cin을 cin.get(), cin.get(ch), cin.get(ch,50) 이렇게 쓰는 것처럼 같은 이름의 함수로 비슷한 기능의 역할을 하는 함수들을 만들었다.

~cpp 
	public Circle(int xValue, int yValue, int width, int height) {
		middlePoint = new Point(xValue, yValue);
		this.width = width;
		this.height = height;
	}
	
	public Circle(int xValue, int yValue, int r){
		middlePoint = new Point(xValue, yValue);
		this.width = r;
		this.height = r;
	}

  • 또 Point(int xValue, int yValue) -> 같이 전달인자를 바로 넣어주어서 보다 간편하게 자료를 입력받을 수 있게 했다.

창재 & 수민 Pair Upload:JavaStudy2003.zip
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:32
Processing time 0.0102 sec