zoukankan      html  css  js  c++  java
  • structure vs class in swift language

    Both class and structure can do:

    • Define properties to store values
    • Define methods to provide functionality
    • Be extended
    • Conform to protocols
    • Define intialisers
    • Define Subscripts to provide access to their variables

    Only class can do:

    • Inheritance
    • Type casting
    • Define deinitialisers
    • Allow reference counting for multiple references.

    Major differences between Structures and Classes:

    • Structures cannot Inherit from other types.
    • Classes use type-casting to treat a class as a superclass or subclass, as well as check protocol adoption. Structs can only use the protocol adoption part.
    • Structures do not have deinitializers.
    • Structures cannot have multiple references to the same instance

    https://stackoverflow.com/questions/24217586/structure-vs-class-in-swift-language

  • 相关阅读:
    HDU 1010 Tempter of the Bone
    HDU 4421 Bit Magic(奇葩式解法)
    HDU 2614 Beat 深搜DFS
    HDU 1495 非常可乐 BFS 搜索
    Road to Cinema
    Sea Battle
    Interview with Oleg
    Spotlights
    Substring
    Dominating Patterns
  • 原文地址:https://www.cnblogs.com/feng9exe/p/9183367.html
Copyright © 2011-2022 走看看