oop(object oriented programming):面向对象程序设计
实例变量默认值初始化为0;
三大特征:
封装(Encapsulation):
封装的目的是对数据进行保护,并且让开发者在修改这类是不需要考虑它的使用细节;
oc 提供简便方法: 用@property代替手动书写setter和getter并且可以通过点号运算符(.) 调用setter和getter;
继承(Inheritance):
方法签名,方法名,形参个数,形參类型
super 当前对象的父类对象
self 当前对象
多态(Polymorphism)
比如:
Person *per=nil;
per=[son new];
[per eat];
per=[uncle new];
[per eat];
id temp=nil;
temp=[son new];
[temp eat];
temp=[uncle new];
[temp eat];