标签:class #import #include object-c 头文件
Main.m
/*
improt和include都是导入文件,
区别是:include只是单纯的复制,
但是import是在导入之前会判断当前文件是否存在已有的文件,
如果没有再导入,否则不会导入
*/
int main(int argc, const char * argv[])
{
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
}
return 0;
}//#import "Classes.h"
/*
@class 可以解决互相导入的问题
@class的作用:告诉编译器在其他地方已经定义了这个类,具体的属性和方法当前文件不知道
*/
<p style="margin-top: 0px; margin-bottom: 0px; font-size: 15px; font-family: Menlo; min-height: 18px;">
</p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 15px; font-family: 'Heiti SC Light'; color: rgb(0, 132, 0);">
</p>
@class Classes;
@interface Student : NSObject {
Classes *classes; //班级
}
- (void)study;
- (void)study {
NSLog(@"学生在学习");
}Classes.h
//#import "Student.h"
//注意:继承的时候不可以在头文件中使用@class,只能只有#import
//@class Student;
@class Student;
@interface Classes : NSObject{
Student *student;
}
标签:class #import #include object-c 头文件
原文地址:http://blog.csdn.net/pengyuan_d/article/details/40402995