-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContents.swift
37 lines (27 loc) · 1.1 KB
/
Contents.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//:Structures
/*
Structures and classes are general-purpose
Comparing Structures and Classes:
===Common stuff===
a)Define properties to store values
b)Define methods to provide functionality
c)Define subscripts to provide access to their values using subscript syntax
d)Extended to expand their functionality beyond default
e)Conform to protocols to provide standard functionality of a certain kind
=======================
Structures cant:
a)iunheritance enables one class to inherit the char of another
b)type casting enables you to check and interpert the type of class instance at runtime
c)deinitializers enable an instance of a class to free up any resources it has assigned
d)Ref counting allows more than one ref to a class instance
*/
//
struct Resolution{
var width = 0
var height = 0
}
let someResolution = Resolution()
print("Width = \(someResolution.width)")
let vga = Resolution(width: 12, height: 12)
//Structures and enumerations are value types
//When passed through a function its value is copied while in classes the refrence of object is passed