Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
June 19, 2018, 05:12:22 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
  Print  
Author Topic: Program 3.3  (Read 1604 times)
rud0lph
Newbie
*
Posts: 2


« on: May 19, 2014, 02:58:16 AM »

Hello im having trouble at the out put

here is the program part for the instance that are causing me trouble:

[myFraccion setNum: 1];
[myFraccion setDen: 3];

[myFraccion2 setNum: 2];
[myFraccion2 setNum: 3];

[myFraccion print];
[myFraccion2 print];

and the result in the console is:

2/3
2/3

why does the values for myFraccion are overwritten, I followed the code as is.
Logged
rud0lph
Newbie
*
Posts: 2


« Reply #1 on: May 19, 2014, 05:30:57 AM »

For everyone who is having this trouble:

The way i solved it is by declaring the variables in the @interface instead of the @implementation, thats the only way i could solve it, the other solutions are not really solutions because the point of the excersice is to comprehend how data can be stored in different instances of the same class so declare your variables as this

@interface fracción: NSObject
{
     int numerator, denominator;
}

-methods-
Logged
Pages: [1]   Go Up
  Print  
 
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 classroomM.com. All rights reserved.