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

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© hei军 中级黑马   /  2015-12-3 00:19  /  540 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

#import <Foundation/Foundation.h>
//父类
@interface Person : NSObject{
    char *_name;//姓名
    double _high;//身高
    double _weight;//体重
}
-(void)run;
-(void)setName:(char *)name;

@end

@implementation Person

-(void)run{
   
    NSLog(@"%s 跑....",_name);
}

-(void)setName:(char *)name{
    _name=name;
}

@end

//警察
@interface Police : Person{
   
    char *_qiang;
}
+(void)catchThief;
@end

@implementation Police


+(void)catchThief{
    NSLog(@"抓小偷...");
}

@end


//小偷
@interface Thief : Person{
    char *_dao;
}
+(void)tou;
@end

@implementation Thief

+(void)tou{
     NSLog(@"偷东西...");
}

@end

int main(){
    //小偷偷东西, 警察跑去抓小偷,小偷跑路
   Thief *t= [Thief new];
    [t setName:"thief"];
    Police *p=[Police new];
    [p setName:"police"];
   
    [Thief tou];
    [p run];
    [Police catchThief];
    [t run];
   
   
   
   
    return 0;
}

0 个回复

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