@ Interface Bird: NSObject
{
}
- (Void) eat;
- (Void) sleep;
@ End
@ Implementation Bird
- (Void) eat
{
NSLog (@ "eating method");
}
- (Void) sleep
{
NSLog (@ "sleep method");
}
@ End
int main (int argc, const char * argv [])
{
/ / @ Autoreleasepool {
/ / Insert code here ...
NSLog (@ "Hello, World!");
id b [0];
b [0] = [Bird new];
[B [0] eat];
/ /
return 0;
}
Program can not call the eat method, suggesting that the god break point seeking advice
Reply:
The wording is too strange.
id b [0]; This is a problem, an array of id type declaration, the array contains 0 elements?
Reply:
Find the correct wording
Reply:
As long as the method is called eat on the line
Reply:
Bird * bird = [[Bird alloc] init];
[Bird eat];
[Bird release];
Reply:
First find the book objective-c to see it.
Reply:
oc is alloc init to construct an instance object. This is somewhat different and java.
break point is to break the problem, not an error.
No comments:
Post a Comment