Im toiling through the book "Learn Objective-C on the Mac". Pretty good book, but the code in chapter 5 looks different than the code in chapter 3, and Im hoping someone can help me understand.
In one instance, a main function looks like this. (Ive trimmed out some repetitive code for the other elements of the array so there is less code to look at.)
int main (int argc, const char * argv[])
{
id shapes[4];
shapes[0] = [Circle new];
drawShapes (shapes, 4);
return (0);
}
Later, the book has a main function that looks like this:
int main (int argc, const char * argv[])
{
Car *car;
car = [Car new];
[car print];
return (0);
}
My question is about the bolded lines. Specifically, why did he need a pointer in the second example ( Car *car; ) but not the first ( id shapes[4]; ) ??
In one instance, a main function looks like this. (Ive trimmed out some repetitive code for the other elements of the array so there is less code to look at.)
int main (int argc, const char * argv[])
{
id shapes[4];
shapes[0] = [Circle new];
drawShapes (shapes, 4);
return (0);
}
Later, the book has a main function that looks like this:
int main (int argc, const char * argv[])
{
Car *car;
car = [Car new];
[car print];
return (0);
}
My question is about the bolded lines. Specifically, why did he need a pointer in the second example ( Car *car; ) but not the first ( id shapes[4]; ) ??