Amazon.com Widgets why this code does not generate an error message
Welcome, Guest. Please login or register.
Did you miss your activation email?
June 18, 2013, 12:18:20 AM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Old Stuff
| |-+  Chapter Study
| | |-+  Chapter 7 - More on Classes
| | | |-+  why this code does not generate an error message
Pages: [1]   Go Down
Print
Author Topic: why this code does not generate an error message  (Read 434 times)
adlene80
Newbie
*
Posts: 2


Email




« on: April 20, 2011, 03:15:57 PM »


the method definition

-(Fraction *) add:(Fraction *) f
{
    Fraction *result =[[Fraction alloc]init];
    result.numerator = numerator * f.denominator +
    denominator * f.numerator;
    result.denominator = denominator * f.denominator;
    [result reduce];
    return result;
}
----------------------------------------------------------------------

the main routine
int main (int argc, const char * argv[])
{

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    Fraction * aFraction = [[Fraction alloc]init];
    Fraction * bFraction = [[Fraction alloc]init];
    Fraction * MyResult;

    // set fraction to 1/3
    [aFraction setTo:1 over:4];
    [aFraction print];
    NSLog(@"+");
    [bFraction setTo:1 over:2];
    [bFraction print];
    NSLog(@"=");
    MyResult = [aFraction add:bFraction];
    [MyResult print];
    [aFraction release];
    [bFraction release];
    [MyResult release];
« Last Edit: April 20, 2011, 03:20:49 PM by adlene80 » Logged
skochan
Administrator
Hero Member
*****
Posts: 3109







« Reply #1 on: May 19, 2011, 01:29:15 PM »

Can you clarify your question?

Cheers,

Steve
Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.