标签:
#import <Foundation/Foundation.h>
@interface Phone : NSObject
{
@public
NSString *_brand;
NSString *_model;
NSString *_color;
float _size;
NSString *_cpu;
}
- (void)aboutMyPhone;
//aboutMyPhone;
//打电话.
- (void)callWithNumber:(NSString *)number;
//callWithNumber:
//发短信
- (void)sendMessage:(NSString *)message toNumber:(NSString *)number;
//sendMessage: toNumber:
@end
@implementation Phone
- (void)aboutMyPhone
{
NSLog(@"\n品牌:%@\n型号:%@\n颜色:%@\n尺寸:%.2f\nCPU:%@",
_brand,_model,_color,_size,_cpu
);
}
- (void)callWithNumber:(NSString *)number
{
NSLog(@"正在呼叫%@",number);
}
- (void)sendMessage:(NSString *)message toNumber:(NSString *)number
{
NSLog(@"正在发送短信【%@】给【%@】",message,number);
}
@end
//姓名:小王
//年龄:19
int main(int argc, const char * argv[])
{
Phone *iPhone = [Phone new];
iPhone->_brand = @"Apple";
iPhone->_color = @"土豪金";
iPhone->_cpu = @"A7";
iPhone->_model = @"iPhone 8S";
iPhone->_size = 7.9f;
[iPhone aboutMyPhone];
[iPhone callWithNumber:@"10086"];
[iPhone sendMessage:@"今天晚上老地方见!" toNumber:@"110"];
return 0;
}
标签:
原文地址:http://www.cnblogs.com/qjrz/p/4649927.html