标签:程序 [] nbsp 结束 程序员 权限 参数传递 ret ons
int main(int argc, const char * argv[]) { // 1.创建士兵对象 Soldier *s1 = [Soldier new]; s1->_name = @"jack"; s1->_life = 10; s1->_level = kSoldierLevel1; // 2.创建枪对象 Gun *gun = [Gun new]; gun->_bulletCount = 100; // 3.射击 [s1 fireByGun:gun]; } @implementation Soldier - (void)fireByGun:(Gun *)gun { [gun shoot]; } @end
@implementation Shop - (Gun *)buyGun { Gun *gun = [Gun new]; gun->_bulletCount = 100; return gun; } @end
标签:程序 [] nbsp 结束 程序员 权限 参数传递 ret ons
原文地址:http://www.cnblogs.com/xufengyuan/p/6537518.html