Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
June 19, 2018, 04:55:38 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
   Home   Help Search Login Register Chat  
Pages: [1]   Go Down
Author Topic: Notation in 7.5  (Read 2041 times)
Silent Radar
Posts: 3

« on: August 05, 2011, 10:03:08 PM »

I understand the concepts being taught, but I got a little lost on the method notation.

I understand that if you use  -(double) it will return a double, but where I get a bit lost is in the example we use -(Fraction *) that returns the new Fraction Object that stores the result of adding 2 fractions. I thought that only keywords could be used like (void), (double), etc could only be used.

I'm pretty new to the programming thing and just looking for some clarification.

Hero Member
Posts: 3114

« Reply #1 on: August 06, 2011, 04:01:05 PM »

You can return any basic C data type (e.g, double, float, int).  That also includes a structure or a pointer (indicated by a *).  These last two are discussed in more detail in Chapter 13.  When you write -(Fraction *), you are specifying that the method will return a pointer. (i.e. reference).  It's a pointer to a Fraction object.    That means you can return references to any type of object, not just fractions.

Hope this helps,

Pages: [1]   Go Up
Jump to:  

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 ゥ 2009 All rights reserved.