#import<Foundation/Foundation.h>
@interface Autobus : NSObject
{
@public
int wheels;
float speed;
}
-(void)run;
-(void)stop;
@end
@implementation Autobus
-(void)run
{
NSLog(@"汽车运行了。。。,现在速度是%.1f",speed);
}
-(void)stop
{
NSLog(@"汽车停止了。。。");
}
@end
int main()
{
Autobus* audi=[Autobus new];
audi->wheels=4;
audi->speed=300;
[audi run];
[audi stop];
audi->speed=500;
[audi run];
[audi stop];
Autobus* toyota=[Autobus new];
toyota->wheels=4;
toyota->speed=200;
[toyota run];
[toyota stop];
return 0;
} |
|