Hi everyone,
I am working on a command line tool program in Mac. In main, I have the following codes:
The code for initWhole:andFractional: in the Mixed class is:
And the interface of Mixed class:
The exception happened at the Mixed code in main above!!!
PS: The Fraction class is in good shape.
Please help me fix this issue. Thanks.
I am working on a command line tool program in Mac. In main, I have the following codes:
Code:
Fraction *p = [[Fraction alloc] initNumerator: 1 andDenominator: 4];
Mixed *a = [[Mixed alloc] initWhole:-1 andFractional: p];
The code for initWhole:andFractional: in the Mixed class is:
Code:
- (id) initWhole: (int) w andFraction: (Fraction *) f
{
if (self == [super init])
{
whole = w;
fractional = [[Fraction alloc] initNumerator: f.numerator andDenominator: f.denominator];
}
return self;
}
And the interface of Mixed class:
Code:
@interface Mixed : NSObject
{
//data
int whole;
Fraction *fractional;
}
The exception happened at the Mixed code in main above!!!
PS: The Fraction class is in good shape.
Please help me fix this issue. Thanks.
Last edited: