看板 C_and_CPP 關於我們 聯絡資訊
快速上升中 前十名目指 obj-c 因應觀眾要求,換個更obj-C的板本 #import <Foundation/Foundation.h> @interface person:NSObject { double weight; } @property double weight; -(double)pound; @end @implementation person @synthesize weight; -(double)pound{ return weight/0.454; } @end int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSLog(@"Enter your weight(kg)"); double weight=0; scanf("%d",&weight); person * I = [[person alloc] init]; [I setWeight:weight]; NSLog(@"Your weight is %d pound",[I pound]); [pool drain]; return 0; } -- 傑米,炸掉它吧。 ⊙─ ─⊙▂⊙ 碰到問題,用C4就對了! █◤ Adam Savage Jamie Hyneman MYTHBUSTERS by dajidali -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.244.225
jlovet:明明跟C沒差別 10/14 16:29
Ebergies:名字都叫 Objective-C 了 lol 10/14 16:38
StubbornLin:天阿 我剛看了一下Objective-C的語法... 10/14 16:43
StubbornLin:怎麼可以這麼惡心... 看到我快吐了 orz 10/14 16:44
StubbornLin:我曾經寫過一點GNU的CObject 已經很惡心了= .= 10/14 16:44
StubbornLin:ObjC...更是... = =" 10/14 16:44
※ 編輯: johnlinvc 來自: 140.112.244.225 (10/14 17:34)