A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始


Person 类
#import <Foundation/Foundation.h>
#import "Computer.h"
@interface Person : NSObject
+(void)playGames:(Computer *)computer;
@end

#import "Person.h"
@implementation Person
+(void)playGames:(Computer *)computer{
   
    [computer playGames];
}
@end


Computer 类
#import <Foundation/Foundation.h>
@interface Computer : NSObject
-(void)playGames;
@end

#import "Computer.h"
@implementation Computer
-(void)playGames{
    NSLog(@"开始玩游戏");
}
@end


#import <Foundation/Foundation.h>
#import "Person.h"
int main(int argc, const char * argv[]) {
    @autoreleasepool {

        Computer *cpu = [Computer new];
        [Person playGames:cpu];
        
    }
    return 0;
}

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马