- #import <Foundation/Foundation.h>
- @interface Person : NSObject
- {
- @public
- int age;
- double weight;
- }
- -(void)walk
- @end
- @implementation Person
- -(viod)walk
- {
- NSLog(@"%d岁,体重%f的人走了一段路",age ,weight);
- }
- @end
- int main()
- {
- Person *p = [Person new];
- p->age = 22
- p->weight = 55.5
-
- Person *p2 = p;
- p2->age = 33;
-
- [p walk];
-
- return 0;
- }
复制代码 上述代码中p和p2都是指针
为什么Person *p2 = p;的书写方式不是Person **p2 = p; 难道不是指向指针的指针吗?求解!!!
|
|