-4

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

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

    double result = 0.0;

    result = operand1 + operand2;

    return result;
}
4

2 回答 2

3

它们是指针,因此您应该取消引用它们:

result = *operand1 + *operand2;

或者更改函数参数:

-(double)performOperationWith:(double )operand1 And:(double )operand2 {...}
于 2013-02-17T11:38:15.457 回答
2

只需删除*

-(double)performOperationWith:(double)operand1  And:(double)operand2 {
    double result = 0.0;
    result = operand1 + operand2;
    return result;
}
于 2013-02-17T11:38:06.297 回答