zoukankan      html  css  js  c++  java
  • ios笔记一(面向对象编程)

    #import <Foundation/Foundation.h>
    #import "Person.h"
    
    int main (int argc, const char * argv[]) {
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
        // insert code here...
        NSLog(@"Hello, World!");
        Person *person = [[Person alloc] initWithAge:30 identify:23452342];
        NSLog(@"person.age:%d",[person getAge]);
        int age = 28;
        [person setAge:age];
        NSLog(@"person.age:%d",[person getAge]);
        [person setAge:++age];
        NSLog(@"person.age: %d",[person getAge]);
        [pool drain];
        return 0;
    }
    #import <Foundation/Foundation.h>
    
    
    @interface Person : NSObject {
        int identify;
        int age;
    }
    - (id) initWithAge:(int) _age identify:(int) _identify;
    - (int) getIdentify;
    - (int) getAge;
    - (void) setAge:(int) _age;
    @end
    #import "Person.h"
    
    
    @implementation Person
    
    - (id) initWithAge:(int) _age identify:(int) _identify
    {
        if (self = [super init]) {
            age = _age;
            identify = _identify;
        }
        return self;
    }
    
    - (int) getIdentify
    {
        return identify;
    }
    
    - (int) getAge
    {
        return age;
    }
    
    - (void) setAge:(int) _age
    {
        age = _age;
    }
    
    @end
  • 相关阅读:
    BZOJ 4525 二分
    BZOJ 4565 状压DP
    BZOJ 3930 容斥原理
    BZOJ 4562 搜索...
    BZOJ 4563 错排+高精度
    BZOJ 1833 数位DP
    BZOJ 4517 组合数+错排
    python 入门学习(二)
    python 入门学习
    Python 爬虫
  • 原文地址:https://www.cnblogs.com/newlist/p/3236015.html
Copyright © 2011-2022 走看看