第一个Objective-C类

//第一个Objective-C类
//编写类的声明
#import<Foundation?Foundation.h>
@interface Iphone: NSObject
{
@public
flaot _model; //型号
int _cpu; //cpu
double _size; //尺寸
int _color; //颜色
}

//行为
@end

//编写类的实现
@implementation Iphone
//行为的实现
@end

int main(int argc, const char * argv[]){
@autoreleasepool{
NSLog(@"Hello,World");

//通过类创建对象
Iphone *p=[Iphone new];
p->_model=4S;
p->_cpu=1;
p->_size=3.5;
p->_color=0;

//获取对象的属性
NSLog(@"model=%f,cpu=%d,size=%f,color=%d",p->_model,p->_cpu,p->_size,p->_color);
}
return 0;
}

posted @ 2016-06-23 22:55  生如夏花~  阅读(76)  评论(0)    收藏  举报