- #import <Foundation/Foundation.h>
- //定义及实现类
- typedef enum{kSexMan,kSexWoman,kSexYao} Sex;
- @interface Person : NSObject
- {
- @public
- NSString *_name;
- Sex _sex;
- }
- -(Person *)changeSex:(Person *) person;
- -(void) disPerson:(Person *) person;
- @end
- @implementation Person
- -(Person *) changeSex:(Person *) person;
- {
- person->_sex = kSexYao;
- return person;
- }
- -(void) disPerson:(Person *) person{
- NSLog(@"姓名:%@,性别:%d",person->_name,person->_sex);
- }
- @end
复制代码
当在main主函数中定义了
Person *p1 = [Person new];
p1 ->_name = @"梅长苏";
后,字符串“梅长苏”和C语言中是否一样存在内存中的ESS段? |
|