Self-test questions of swift-class and structural body

Source: Internet
Author: User
<pre name= "code" class= "Python" >1. There is a struct and class, defined as follows <pre name= "code" class= "java" >struct Resolution {
    var width = 0
    var heigth = 0
}
class Videomode {
    var Resolution = Resolution ()
    var interlaced = False
    var framerate = 0.0
    var name:string?
}



Let HD = Resolution (width:1920, height:1080)
var cinema = HD
cinema.width = 2048
println ("Cinema was now \ (cinema.width) pixels wide ")
<pre name=" code "class=" Python ">println (" HD is now \ (hd.width) pixels wide ")

Above when output statement output what separately.

Let teneighty = Videomode ()
teneighty.resolution = HD
teneighty.interlaced = true
teneighty.name = "1080i" C3/>teneighty.framerate = 25.0 let
alsoteneighty = teneighty
alsoteneighty.framerate = 30.0

println ("the Framerate property of Teneighty was now \ (teneighty.framerate) ")

above when output.


This is the difference between a value type and a reference type.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.