- #import <Foundation/Foundation.h>
- @interface Person : NSObject
- {
- @public
- int age;
- double weight;
- }
- -(void)walk;
- @end
- @implementation Person
- -(void)walk
- {
- NSLog(@"年龄是%d、体重是%.2f的人在散步。",age,weight); //为什么不是p-〉age
- }
- @end
- int main()
- {
- Person *p = [Person new];
- p->age = 30;
- p->weight =70;
- [p walk];
- return 0;
- }
复制代码
如上所示,在方法中的两个属性变量为什么不是p->age 和 p->weight,而是不加p呢?求两者区别,谢谢 |
|