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 }

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

  • 相关阅读:
    git学习
    小程序强制自动更新
    UI设计规范
    2019前端面试题汇总(vue)
    技术面试笔试题
    阿里云万网虚拟主机安装配置Https(SSL)教程
    [转]Vue项目全局配置微信分享思路详解
    Elasticsearch学习笔记之—分词器 analyzer
    合成图片+合成文字+图片
    C# 在Bitmap上绘制文字出现锯齿的问题
  • 原文地址:https://www.cnblogs.com/chenxiangxi/p/2456883.html
Copyright © 2011-2022 走看看