本帖最后由 傘が咲く 于 2014-5-6 20:56 编辑
- #import <Foundation/Foundation.h>
- @interface Student : NSObject
- {
- @public
- char *name;
- int stu_id;
- }
- - (void)study;
- @end
- @implementation Student
- - (void)study
- {
- NSLog(@"%s,%d学会了很多东西!!",name,stu_id);
- }
- @end
- int main()
- {
- Student *stu1 = [Student new];
- Student *stu2 = [Student new];
- stu1->name = "zhangsan";
- stu1->stu_id = 123;
-
- stu2->name = "lisi";
- stu2->stu_id = 124;
-
- [stu1 study];
- [stu2 study];//这两个对象调用的 study方法是否是同一个?
- return 0;
- }
复制代码java的对象里有类的方法,问上述代码里两个Student对象里有没有类中的study方法,与java对象有何区别!{:3_66:}
|