#import <Foundation/Foundation.h>
@interface Dog :NSObject{
@public
NSString *_name;
}
-(void)bitOtherDog:(Dog *) otherDog;
@end
@implementation Dog
- (void) bitOtherDog:(Dog *) otherDog{
NSLog(@"%@ bit other dog %@", _name, otherDog->_name);
}
@end
@interface Person :NSObject{
@public
NSString *_username;
int _age;
}
-(void)orderDog :(Dog *) dog bitOhterDog:(Dog *) other;
-(Dog *) selDog;
@end
@implementation Person
-(void)orderDog :(Dog *) dog bitOhterDog:(Dog *) other{
NSLog(@"%@ order dog", _username);
[dog bitOtherDog:other];
}
-(Dog *) selDog{
return [Dog new];
}
@end
int main(int argc, const char * argv[])
{
@autoreleasepool {
Dog *dog = [Dog new];
dog ->_name = @"tom";
Dog *otherDog = [Dog new];
otherDog ->_name = @"jack";
[dog bitOtherDog:otherDog];
Person *p = [Person new];
p->_username = @"lovoo";
[p orderDog:dog bitOhterDog:otherDog];
Dog *selDog = [p selDog];
}
return 0;
}