- #import <Foundation/Foundation.h>
- #import "Person.h"
- #import "Teacher.h"
- #import "Student.h"
- int main(int argc, const char * argv[])
- {
- @autoreleasepool {
-
- Student *stu=[Student new];
- stu.name=@"小明";
- [stu show];
- Teacher *tec=[Teacher new];
- tec.name=@"王五";
- [tec show];
- }
- return 0;
- }
复制代码输出:
2014-04-07 09:45:55.800 多态[1669:303] 我是小明
2014-04-07 09:45:55.810 多态[1669:303] 我是王五