objectc class类操作示例代码

代码语言:objectc

所属分类:其他

代码描述:objectc class类操作示例代码

代码标签: 操作 示例

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

#import <Foundation/Foundation.h>

@interface Box:NSObject {
   double length;    // Length of a box
   double breadth;   // Breadth of a box
   double height;    // Height of a box
}

@property(nonatomic, readwrite) double height;  // Property
-(double) volume;
@end

@implementation Box

@synthesize height; 

-(id)init {
   self = [super init];
   length = 1.0;
   breadth = 1.0;
   return self;
}

-(double) volume {
   return length*breadth*height;
}

@end

int main() {
   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];    
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0