zoukankan      html  css  js  c++  java
  • 面向对象编程增加间接层对程序的扩展

    一下通过代码做出解释:

    View Code
     1 #import <Foundation/Foundation.h>
     2 int main(int argc, const char * argv[])
     3 {
     4     @autoreleasepool
     5     {
     6         NSLog(@"The numbers forme 1 to 5");
     7         for(int i = 1; i <= 5; i++)
     8         {
     9              NSLog(@"%d\n", i);
    10         }
    11     }
    12     return 0;
    13 }
    View Code
     1 #import <Foundation/Foundation.h>
     2 int main(int argc, const char * argv[])
     3 {
     4     @autoreleasepool
     5     {
     6         int count = 5;
     7         NSLog(@"The numbers forme 1 to %d", count);
     8         for(int i = 1; i <= count; i++)
     9         {
    10              NSLog(@"%d\n", i);
    11         }
    12     }
    13     return 0;
    14 }
    View Code
     1 #import <Foundation/Foundation.h>
     2 int main(int argc, const char * argv[])
     3 {
     4     @autoreleasepool
     5     {
     6         int fist = 1, count = 5;
     7         NSLog(@"The numbers forme %d to %d", fist, count);
     8         for(int i = fist; i <= count; i++)
     9         {
    10              NSLog(@"%d\n", i);
    11         }
    12     }
    13     return 0;
    14 }
    View Code
     1 #import <Foundation/Foundation.h>
     2 int main(int argc, const char * argv[])
     3 {
     4     @autoreleasepool
     5     {
     6         int fist, count;
     7         scanf("%d %d", &fist, &count);
     8         NSLog(@"The numbers forme %d to %d", fist, count);
     9         for(int i = fist; i <= count; i++)
    10         {
    11              NSLog(@"%d\n", i);
    12         }
    13     }
    14     return 0;
    15 }

    请观察以上代码,发现是怎么一步一步的对程序扩展的,相信你就的增加一个间接层就有所了解了。

  • 相关阅读:
    openstack-9块存储服务(此服务可选)
    openstack-7dashboard(仪表盘)
    openstack-6neutron(网络服务)
    openstack-5computer(计算服务)
    openstack-4glance(镜像服务)
    openstack-12补充
    openstack-10实现VPC自定义网络
    openstack-8实现内外网结构
    openstack-3keystone(认证服务)
    js实现填写身份证号、手机号、准考证号等信息自动空格的效果
  • 原文地址:https://www.cnblogs.com/chenxiangxi/p/2456883.html
Copyright © 2011-2022 走看看