代码1:
@implementation Calculator
-(void)add{
_result=_num1+_num2;
}
-(void)subduction{
_result=_num1-_num2;
}
-(vodi)multiplication{
_result=_num1*_num2;
}
-(void)division{
_result=_num1/(float)_num2;
}
@end
代码2:
@implementation Calculator
-(int)add{
_result=_num1+_num2;
}
-(int)subduction{
_result=_num1-_num2;
}
-(int)multiplication{
_result=_num1*_num2;
}
-(float)division{
_result=_num1/(float)_num2;
}
@end
自学过基础班视屏的同学还记得不?老师把没有参数的代码1改为有参数的代码2后能够节省堆中的内存空间,为什么说能够节省空间呢?感觉不是很明白……
|
|