#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

 

相关文章:

  • 2021-06-23
  • 2022-12-23
  • 2022-01-23
  • 2021-05-24
  • 2021-12-23
  • 2021-07-16
  • 2021-11-21
  • 2021-07-26
猜你喜欢
  • 2021-11-04
  • 2021-10-18
  • 2021-08-05
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案