Amazon.com Widgets Notation in 7.5
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 22, 2014, 10:41:08 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
| |-+ Program Examples
| | |-+ Chapter 7
| | | |-+ Notation in 7.5
Pages: [1] Go Down
Print
Author Topic: Notation in 7.5 (Read 1097 times)
Silent Radar
Newbie
*
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.

Thanks
Logged
skochan
Administrator
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,

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.