+ 4

Swift 4

class MarksStruct { var mark: Int init(mark: Int) { self.mark = mark } } class studentMarks { var mark = 300 } let marks = studentMarks() print("Mark is \(marks.mark)") why class is declared twice? are we connecting to the first one?

5th Mar 2018, 5:41 AM
Ugiloy Boymirzaeva
Ugiloy Boymirzaeva - avatar
1 Answer
+ 1
I don't see declare twice of class in your code. You mean 'marks.mark' ? If so, you just use the marks instance of studentMarks class and access its variable 'mark' using dot notation. Output will be 300.
5th Mar 2018, 6:11 AM
Sylar