文章标题
来源:互联网 发布:淘宝标题如何自动生成 编辑:程序博客网 时间:2024/05/21 18:50
@interface Person : NSObject{ NSString *_name; NSString *_sex; int _age;}//setter方法-(void)setName:(NSString *)name;-(void)setSex:(NSString *)sex;-(void)setAge:(int)age;@end@implementation Person//setter方法-(void)setName:(NSString *)name{ _name = name;}-(void)setSex:(NSString *)sex{ _sex = sex;}-(void)setAge:(int)age{ _age = age;}@end@interface Student : Person{ NSString *_studentID; float _score;}//setter-(void)setStudentID:(NSString *)studentID;-(void)setScore:(float)score;@end@implementation Student : Person//setter-(void)setStudentID:(NSString *)studentID{ _studentID = studentID;}-(void)setScore:(float)score{ _score = score;}@endint main(){ Student *stu = [[Student alloc]init];//开辟空间调用初始化方法 //使用setter方法为实例变量赋值。 [stu setName:@"xiaoA"]; [stu setSex:@"Man"]; [stu setAge:15]; [stu setStudentID:@"2008-07"]; [stu setScore:96]; return 0;}
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- js中创建UUID
- 粒子在UI后面显示解决方案
- 设计模式之PHP项目应用——策略模式设计商场收银系统
- Hadoop文件格式
- python3与sqlite3
- 文章标题
- 835全讯网为你解常见的操盘手法
- ArrayList和LinkedList区别
- 每天一个(设计模式)-- Bridge模式(桥接模式)
- 【freemarker详解】—— Freemarker常用技巧
- 数字水印初谈
- 【Linux开发】linux线程同步方式互斥锁介绍及实例
- 请!继续!
- Linux性能测试 pmap命令