Revias Blog
분류 전체보기
(25)
잡다한것들
(0)
프로그래밍
(6)
내 마음대로 Direct X
(0)
Assembler
(1)
C/C++
(0)
html&js
(2)
opengl
(1)
Objective-C
(1)
iPhone
(0)
참고자료
(7)
자료
(8)
trash
(0)
홈
태그
미디어로그
위치로그
방명록
/
/
블로그 내 검색
프로그래밍/Objective-C
클래스, 객체, 메서드
2012.02.22
클래스, 객체, 메서드
레비아스
2012. 2. 22. 22:05
2012. 2. 22. 22:05
#import <Foundation/Foundation.h> @interface Fraction: NSObject { int numerator; int denominator; } -(void) print; -(void) setNumerator; -(void) setDenominator; @end // ---- implementation부분 ---- @implementation Fraction -(void) print { NSLog(@"%i / %i", numerator, denominator); } -(void) setNumerator: (int) n { numerator = n; } -(void) setDenominator: (int) d { denominator = d; } @end // 결과 부분. int main (int argc, const char * argv[]) { @autoreleasepool { Fraction *myFraction; //Fraction의 인스턴스를 생성. myFraction = [Fraction alloc]; myFraction = [myFraction init]; [myFraction setNumerator: 1]; [myFraction setDenominator: 3]; NSLog(@"\nThe value of myFraction is:"); [myFraction print]; [myFraction release]; return 0; } }
좀 더 쉽게 풀이 후 적도록 할것이다.
공유하기
게시글 관리
Revias Blog
저작자표시
PREV
이전
1
NEXT
다음
+ Recent posts
Powered by
Tistory
, Designed by
wallel
Rss Feed
and
Twitter
,
Facebook
,
Youtube
,
Google+
티스토리툴바