1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| #include <Foundation/Foundation.h>
@interface JiSuanQi : NSObject -(double)pi; -(int)pingFang:(int)num; -(int)sum:(int)num1:(int)num2; -(int)sumWithNum1:(int)num1 andNum2:(int)num2; -(int)sumWithNum1:(int)num1 andNum2:(int)num2 andNum3:(int)num3;
@end
@implementation JiSuanQi
-(double)pi { return 3.14; } -(int)pingFang:(int)num { return num*num; } -(int)sum:(int)num1:(int)num2 { return num1+num2; } -(int)sumWithNum1:(int)num1 andNum2:(int)num2 { return num1+num2; } -(int)sumWithNum1:(int)num1 andNum2:(int)num2 andNum3:(int)num3 { return num1+num2+num3; } @end
int main() { JiSuanQi *jsq=[JiSuanQi new]; int pingFang=[jsq pingFang:10]; //int sum=[jsq sum: 10: 5]; int sum=[jsq sumWithNum1:10 andNum2:5]; NSLog(@"pingFang=%d",pingFang); NSLog(@"sum=%d",sum); //double pi= [jsq pi]; //NSLog(@"pi的之是%f",pi); return 0; }
|