Objective-C 类的基础程序
来源:互联网 发布:淘宝详情页跳出率70% 编辑:程序博客网 时间:2024/05/18 07:28
#import <Foundation/Foundation.h>@interface Fraction:NSObject{ @private//访问权限有public,protected,private ,三种,若未指定,缺省为protected int numbertor; int denomiator;}-(void) print;-(void) setNumerator: (int) n;-(void) setDenomiator: (int) d;//数据封装-(int)numbertor;-(int)denomiator;@end@implementation Fraction-(void) print{ //return ((@"%i/%i",numbertor,denomiator)); NSLog(@"%i/%i",numbertor,denomiator);}-(void) setNumerator: (int) n{ numbertor=n; return ;}-(void) setDenomiator:(int)d{ denomiator=d; return ;}-(int)numbertor{ return numbertor;}-(int)denomiator{ return denomiator;}@endint main(int argc, const char * argv[]){ @autoreleasepool { // insert code here... // NSLog(@"Hello, World!"); Fraction *myFraction=[[Fraction alloc] init]; [myFraction setNumerator:1]; [myFraction setDenomiator:3]; NSLog(@"The value is"); [myFraction print]; NSLog(@"%i %i ",[myFraction numbertor],[myFraction denomiator]); } return 0;}
0 0
- Objective-C 类的基础程序
- Xcode基础:详解Objective-C开发带有图形界面的程序
- Objective-C基础——简单的OC程序
- Objective-C开发——最简单的Objective-C程序与基础语法解析
- Objective-C类 基础
- objective-c的常用基础类
- objective C 基础 类的组成
- Objective-C基础-类方法的学习
- Objective-C基础—预处理程序
- Objective-c的Block基础
- Objective-C 基础集合类
- Objective-C 类基础(二)
- Objective-C 类基础(三)
- 【Objective-C基础】集合类
- Objective-C基础---Objective-C的特有语法
- Objective-c基础(二)-类的定义
- Objective - C基础: 第二天 - 5.类方法的练习
- Objective - C基础: 第四天 - 6.类的本质
- 根据端口号查询进程pid,netstat -nptl
- poj1947 Rebuilding Roads
- 人脸识别经典算法二:LBP方法
- 关于使用RijndaelManaged 类加密解密数据的小结
- Android的Handler总结
- Objective-C 类的基础程序
- 浅析 Linux 中的时间编程和实现原理,第 1 部分: Linux 应用层的时间编程
- 2014年4月7日 再次深入激辩余额宝
- 毕业四年
- 大数据时代:GDP统计过时了吗?
- Linux网络编程socket错误分析
- 利用单例模式解决WinForm中子窗体只允许打开一次的问题
- 动态规划之多段图(上)
- Linux下pdf乱码解决方案