#import <Foundation/Foundation.h>
// :表示继承,只能是单继承
@interface Person : NSObject
- (void)test: / /对象方法的声明
@end
@implementation Person
- (void)test{ // 对象方法的实现
insert code in here........
}
@end
@interface Car : NSObject
{// 成员变量\实例变量
//int wheels = 4; 不允许在这里初始化
//static int wheels; 不能随便将成员变量当做C语言中的变量来使用
@public
int wheels;
}
- (void)run;
- (void)fly;
@end
int main()
{
// wheels = 10;
void test2(); /
test2();
return 0;
}
@implementation Car
- (void) fly
{
}
void test()
{
NSLog(@"调用了test函数");
}
- (void)run
{
test();
NSLog(@"%d个轮子的车跑起来了", wheels);
}
@end