December 2013
Beginner
576 pages
16h 4m
English
Can you explain the output from Program 8.5?
Program 8.5
#import "Rectangle.h"#import "XYPoint.h"int main (int argc, char * argv[]){ @autoreleasepool { Rectangle *myRect = [[Rectangle alloc] init]; XYPoint *myPoint = [[XYPoint alloc] init]; [myPoint setX: 100 andY: 200]; [myRect setWidth: 5 andHeight: 8]; myRect.origin = myPoint; NSLog (@"Origin at (%i, %i)", myRect.origin.x, myRect.origin.y); [myPoint setX: 50 andY: 50]; NSLog (@"Origin at (%i, %i)", myRect.origin.x, myRect.origin.y); } return 0;}
Program 8.5 Output
Origin at (100, 200)Origin at (50, 50)
You changed myPoint from (100, 200) in the program to (50, 50), and apparently ...
Read now
Unlock full access