hello,
I'm learning Obj-C and i reached where it teach me how to add Methods without argument names so here is my implementation section code:
the error is:
error: requests for member 'denominator' in something is not a structure or union
I'm learning Obj-C and i reached where it teach me how to add Methods without argument names so here is my implementation section code:
Code:
//
// Fraction.m
// FractionTest
//
// Created by Fahad Ali on 12/08/2009.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "Fraction.h"
@implementation Fraction
-(void) print {
NSLog (@"%i/%i", numerator, denominator);
}
-(double) convertToNum {
if (denominator != 0) return (double) numerator / denominator;
else return 1.0;
}
-(void) setTo: (int) n over: (int) d
{
numerator = n;
denominator = d;
}
- (void) add: (Fraction *) f
{
// To add two fractions: // a/b + c/d = ((a*d) + (b*c)) / (b * d)
numerator = numerator * f.denominator + denominator * f.numerator;
denominator = denominator * f.denominator;
}
@end
the error is:
error: requests for member 'denominator' in something is not a structure or union