#import <Foundation/Foundation.h>@interface Complex : NSObject
@property double real, imaginary;-(void) print;
-(void) setReal: (double) a andImageinary: (double) b;
-(Complex *) add: (Complex *) f;
@end北京-小小鸟: 13:54:07#import "Complex.h"@implementation Complex@synthesize real, imaginary;-(void) print
{
NSLog(@" %g + %gi", real, imaginary);
}-(void) setReal:(double) a andImaginary: (double) b
{
real = a;
imaginary = b;
}-(Complex *) add:(Complex *)f
{
Complex* result = [[Complex alloc]init];
result.real = real + f.real;
result.imaginary = imaginary + f.imaginary;
return result;
}@end @autoreleasepool {
id dataValue;
Fraction* f1 = [[Fraction alloc] init];
Complex* c1 = [[Complex alloc] init];
[f1 setTo:2 over: 5];
[c1 setReal: 10.0 andImageinary:2.5];
dataValue = f1;
[dataValue print];
}执行 [c1 setReal: 10.0 andImageinary:2.5]; 时报错?不知道为啥,请高手,帮忙看一眼,感谢
应为:- (void) setReal:(double)a andImageinary:(double)bandImaginary
andImageinary