OC 总结一

2018-06-14  本文已影响15人  CaptainRoy
NSLog(@"size of int : %lu",sizeof(int)); // size of int : 4
NSLog(@"size of long int : %lu",sizeof(long int)); // size of long int : 8
NSLog(@"size of short int : %lu",sizeof(short int)); // size of short int : 2
NSLog(@"size of unsigned int : %lu",sizeof(unsigned int)); // size of unsigned int : 4
NSLog(@"size of long long int : %lu",sizeof(long long int)); // size of long long int : 8
NSLog(@"size of double : %lu",sizeof(double)); // size of double : 8
NSLog(@"size of long double : %lu",sizeof(long double)); // size of long double : 16
NSLog(@"size of float : %lu",sizeof(float)); // size of float : 4

long 可以扩展值域
short 节约内存
unsigned 用来存储正整数

int a = 25;
int b = 2;
NSLog(@" a / b = %d",a/b); // a / b = 12
NSLog(@" a %% b = %d ",a%b); // a % b = 1
int i = 0;
NSLog(@"请输入您的年龄: ");
scanf("%i",&i);
NSLog(@"您的年龄是: %d 岁",i);
// 消息结构
Object *obj = [Object new];
[obj performWith:param1 and:param2];
        
// 函数调用
Object *obj = new Object;
obj->perform(param1,param2);
上一篇下一篇

猜你喜欢

热点阅读