swift的static和class修饰符---What is the difference between static func and class func in Swift?
Special Kinds of Methods
Methods associated with a type rather than an instance of a type must be marked with the static declaration modifier for enumerations and structures, or with either the static or class declaration modifier for classes. A class type method marked with the class declaration modifier can be overridden by a subclass implementation; a class type method marked with static can’t be overridden.
Variable Declaration
A variable declaration introduces a variable named value into your program and is declared using the var keyword.
Variable declarations have several forms that declare different kinds of named, mutable values, including stored and computed variables and properties, stored variable and property observers, and static variable properties.
Type Variable Properties
To declare a type variable property, mark the declaration with the static declaration modifier. Classes may mark type computed properties with the class declaration modifier instead to allow subclasses to override the superclass’s implementation. Type properties are discussed in Type Properties.
In a class declaration, the static keyword has the same effect as marking the declaration with both the class and final declaration modifiers.
Protocol Method Declaration
To declare a class or static method requirement in a protocol declaration, mark the method declaration with the static declaration modifier. Classes that implement this method declare the method with the class modifier. Structures that implement it must declare the method with the static declaration modifier instead. If you’re implementing the method in an extension, use the class modifier if you’re extending a class and the static modifier if you’re extending a structure
https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#//apple_ref/doc/uid/TP40014097-CH34-ID483
swift的static和class修饰符---What is the difference between static func and class func in Swift?的更多相关文章
- JAVA基础-栈与堆,static、final修饰符、内部类和Java内存分配
Java栈与堆 堆:顺序随意 栈:后进先出(Last-in/First-Out). Java的堆是一个运行时数据区,类的对象从中分配空间.这些对象通过new.newarray.anewarray和mu ...
- 浅析java修饰符之public default protected private static final abstract
浅析java修饰符之public default protected private static final abstract 一 修饰符的作用:用来定义类.方法或者变量,通常放在语句的最前端 ...
- java中static和final修饰符
static和final修饰符 一.static修饰符 static表示“全局”或者“静态”的意思,用来修饰成员变量和成员方法,也可以形成静态static代码块,但是Java语言中没有全局变量的概念. ...
- swift static与class修饰符:static不参与动态派发
static与class 都有类型成员的含义:相对于实例成员: static的另一个意思是静态派发:所以不能被继承. 要使用动态派发和继承的机制必须使用class继承. static的其它常见含义: ...
- 类的高级:访问修饰符、封装、静态类成员static、内部类;
访问修饰符: 公开访问(public):对所有子类,非子类访问: 受保护的(protected):只有同包子类.非子类.不同包子类可访问,不同包非子类不可访问: 私有的(private):只有本类可访 ...
- Java中static、final修饰符、对常量变量的总结
static static属性 定义:static修饰的属性就叫静态属性:如果类的某个属性,不管创建多少个对象,属性的存储空间只有唯一的一个,那么这个属性就应该用static修饰 作用:static属 ...
- static、final修饰符、内部类
static修饰符: static修饰符能够与属性.方法和内部类一起使用,表示静态的.类中的静态变量和静态方法能够与类名一起使用.不须要创建一个类的对象来訪问该类的静态成员. class Static ...
- Java从入门到放弃——05.修饰符static,final,权限修饰符
本文目标 static final: 权限修饰符:public,private,protected,缺省 1.static 静态修饰符,被static修饰的变量或者方法会被加载进静态区内存,不需要创建 ...
- static 与 final 修饰符
A) 用static(静态)修饰属性:一个类生成了N个对象,这些对象会共同使用一份静态的成员变量.一个对象对这个成员变量进行修改,其他对象的该成员变量的值也会随之变化. B) 我们可以通过 类名.成员 ...
随机推荐
- LINUX-进程的概念
计算机中,CPU是最宝贵的资源,为了提高CPU的利用率,引入了多道程序设计的概念.当内存中多个程序存在时,如果不对人们熟悉的“程序”的概念加以扩充,就无法刻画多个程序共同运行时系统呈现出的特征. 一. ...
- 【转】Chrome headless 模式
原文地址: http://www.cnblogs.com/fnng/p/7797839.html 我们在通过Selenium运行自动化测试时,必须要启动浏览器,浏览器的启动与关闭必然会影响执行效率,而 ...
- bzoj4555
ntt+cdq分治 原来zwh出的cf是斯特林 第二类斯特林数的定义是S(i,j)表示将i个物品分到j个无序集合的方案数,那么这道题中S(i,j)*j!*2^j是指将i个物品分到j个有序集合中并且每个 ...
- springmvc不进入Controller导致404
转自:https://blog.csdn.net/qq_36769100/article/details/71746449#1.%E5%90%AF%E5%8A%A8%E9%A1%B9%E7%9B%AE ...
- View Controller Programming Guide for iOS---(一)---About View Controllers
About View Controllers View controllers are a vital link between an app’s data and its visual appear ...
- windows下patch
经常在网上看到有人发布patch文件来更新他们的开源代码,例如cegui.ogre等都使用这种形式来修bug或者增加一些小功能.但是,我们下载到的patch文件,貌似是linux/unix的diff工 ...
- MySQL命令行参数
一,mysql命令行参数 Usage: mysql [OPTIONS] [database] //命令方式 -?, --help //显示帮助信息并退出 -I, --help ...
- Python2/3共存,pip2/3共存
python2 和 python3设置: 1.安装Python2和3,并添加环境变量: 2.找到python2和python3的安装目录,修改python2中和python3中python.exe和p ...
- bzoj 3230: 相似子串【SA+st表+二分】
总是犯低级错误,st表都能写错-- 正反分别做一遍SA,预处理st表方便查询lcp,然后处理a[i]表示前i个后缀一共有多少个本质不同的子串,这里的子串是按字典序的,所以询问的时候直接在a上二分排名就 ...
- bzoj 3172: [Tjoi2013]单词【AC自动机】
一眼AC自动机,就是先把串建一个自动机,标记每个串在自动机上的位置,然后加上间隔符连成一个串在自动机上跑,每跑到一个点就说明这个串以及它到root的所有点表示的串都要被更新一次 先在点上打上标记,最后 ...