logo
  • 教程列表
  • SO官方文檔
  • 結構
    • 結構是值型別
    • 結構基礎知識
    • 改變結構
    • 結構不能繼承
    • 訪問 struct 的成員
  1. StackOverflow 文件
  2. Swift Language 教程
  3. 結構
  4. 結構不能繼承

結構不能繼承

Created: November-22, 2018

與類不同,結構不能繼承:

class MyView: NSView { }  // works

struct MyInt: Int { } // error: inheritance from non-protocol type 'Int'

但是,結構可以採用協議:

struct Vector: Hashable { ... }  // works
  • 訪問 struct 的成員
  • 改變結構

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明