2011-01-31 25 views
1

我構建了一個類並創建了初始化所有變量的方法。在.H錯誤:賦值中的不兼容類型

-(void) initWithX:(float *)x_ andY:(float *)y_ andWidth:(float *)width_; 

和.M

-(void) initWithX:(float *)x_ andY:(float *)y_ andWidth:(float *)width_{ 
    [super init]; 
    x = x_; *** 
    y = y_; *** 
    width = width_; *** 
} 

線,*給我 「在分配類型不兼容」 的錯誤,但我不明白:我給在.h中告訴的3個浮動

謝謝大家

回答

5

通過移除*通過值傳遞的花車:

- (void)initWithX:(float)x_ andY:(float)y_ andWidth:(float)width_; 

- (void)initWithX:(float)x_ andY:(float)y_ andWidth:(float)width_ { 
    [super init]; 
    x = x_; 
    y = y_; 
    width = width_; 
} 

。否則,方法是要求指針到彩車(float *),而不是他們的實際基本

1

您正在詢問浮點指針,並可能將它們指定給浮點變量。取出方法聲明中的星號。