二进制表达式的操作数无效('double'和'double')objective-c问题

时间:2013-02-17 11:35:04

标签: iphone ios objective-c

二进制表达式的操作数无效('double'和'double')objective-c issue

-(double)performOperationWith:(double *)operand1 
                         And:(double *)operand2 {

    double result = 0.0;

    result = operand1 + operand2;

    return result;
}

2 个答案:

答案 0 :(得分:3)

他们是指针,所以你应该取消引用它们:

result = *operand1 + *operand2;

或更改功能参数:

-(double)performOperationWith:(double )operand1 And:(double )operand2 {...}

答案 1 :(得分:2)

只需删除*

即可
-(double)performOperationWith:(double)operand1  And:(double)operand2 {
    double result = 0.0;
    result = operand1 + operand2;
    return result;
}