Arrays as Parameters?
I'm a C/C++ programmer until recently when I found a lot of enjoyment in Cocoa and ObjC, but one thing I can't get is having an array as a parameter to a method. Is this possible in ObjC? I thought it'd look like this - (int)findTotal: (int)hand[] but that gives me an error: BlackjackView.m:118: error: parse error before '[' token. Any help is appreciated.
I don't have time to check, but shouldn't it be:
If that doesn't work just pass it as a pointer to an int, then you can just use it like an array anyway.
Just be careful not to go out of bounds, but you already new that I'm sure.
Code:
- (int)findTotal: (int[])handIf that doesn't work just pass it as a pointer to an int, then you can just use it like an array anyway.
Code:
- (int)findTotal: (int)*hand
//then somewhere...
hand[5] = 5;Just be careful not to go out of bounds, but you already new that I'm sure.
Thanks a lot. I'll give them a try.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| C: Global Variables versus Parameters | Lizard Man | 10 | 4,996 |
Jan 13, 2010 08:22 PM Last Post: Lizard Man |
|

