2015.7.9 OC学习第三天
2015-07-09 10:26
357 查看
1.成员变量属于实例变量的一部分,所有的指针变量都是实例变量
2.OC和UI中只要继承NSObject的类,统称为model(模型)类
3.OC中没有多继承,协议是间接实现多继承的方式
4.继承中子类继承父类的所有东西,所以不能用@class 必须用import
people.h
people.m
main.m
输出
2.OC和UI中只要继承NSObject的类,统称为model(模型)类
3.OC中没有多继承,协议是间接实现多继承的方式
4.继承中子类继承父类的所有东西,所以不能用@class 必须用import
people.h
#import <Foundation/Foundation.h> @interface People : NSObject { NSString *_name; NSString *_sex; NSInteger _age; } - (void)eat;
people.m
- (void)eat { NSLog(@"吃食物"); NSLog(@"self = %@", self); }student.h
@interface Student : People { NSString *_school; NSInteger _number; } @endstudent.m
- (void)eat { NSLog(@"吃饭"); //重写父类的方法,不需要再次声明 }
main.m
Student *student = [[Student alloc]init]; [student eat]; NSLog(@"student = %@", student);
输出
2015-07-09 10:23:37.423 20150709 OC[4754:354107] 吃饭 2015-07-09 10:23:37.424 20150709 OC[4754:354107] student = <Student: 0x1001110e0> Program ended with exit code: 0
相关文章推荐
- [设计模式]<<设计模式之禅>>关于里氏替换原则
- css3 webkit-box的用法
- 安卓hook
- 解决自定义文件上传处理与Spring MultipartResolver的冲突问题
- WebView基本使用
- DrawerLayout Demo
- SVN:回滚代码
- 自定义应用程序配置文件(app.config)
- struts2标签
- [设计模式]<<设计模式之禅>>之关于单一职责原则
- 程序安装莫名其妙失败的解决方法,程序未彻底卸载
- [TOOLS] SSH上传下载
- loadView、viewDidLoad及viewDidUnload的关系
- 给“夜猫子”程序员的科学熬夜指南
- Linux ./configure,make,make install的作用
- ini_set的用法介绍
- 在应用里面获取系统字体大小
- Hibernate核心接口简介
- 学习:Dom4j和Xpath
- POJ 3673:Cow Multiplication