zoukankan      html  css  js  c++  java
  • X++ 学习 (四)

    方法和变量

    1.方法的重载

    跟Java一样的机制,默认情况下可以override,如果要把某个方法设为不可override,则要使用关键字final,要把某个类设为不可继承,也使用该关键字(C#里是sealed)

    2.支持嵌入函数
    void MyMethod()
    {
      
    void MyFunction() //Embedded function only has scope within
      MyMethod
      {
        
    //some statements
      }
      MyFunction();
    }

    这个在C++,Java,C#中都不支持.不过貌似意义不是太大。

    3.静态成员
    class MyClass
    {
      
    //Variables could go here
      static void MyMethod()
      {
        
    // some statements
      }
      
    void MyMethod()
      {
        
    // some statements
      }
    }

    这个在C#里是不允许的,static不属于方法的签名,这两个方法属于同名方法。
    调用

    void SomeMethod()
    {
      MyClass mc 
    = new MyClass();
      mc.MyMethod(); 
    /* The method in the current instance of the class (the object referred to as mc) is invoked.*/
      mc::MyMethod(); 
    // The static method in the class is invoked
    }
  • 相关阅读:
    数据分析三剑客numpy pandas Matplotlib
    算法 初识
    python 爬虫二
    python 爬虫一
    python celery
    elasticsearch 学习
    ansible 基本使用
    面试题
    奇技淫巧
    【前端基础】- CSS 1-CSS选择器
  • 原文地址:https://www.cnblogs.com/Kurodo/p/2105493.html
Copyright © 2011-2022 走看看