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

    }

  • 相关阅读:
    MCU开发之I2C通信
    hibernate特殊的映射
    Hibernate使用
    css设置让a标签充满整个li
    margin
    border属性
    列表
    链接样式
    相机内参外参
    tmux
  • 原文地址:https://www.cnblogs.com/Farseer1215/p/330838.html
Copyright © 2011-2022 走看看