Saturday, 7 November 2020

Swift Reference Types - OOPS

 In reference type we can store the memory address location into the instance of the class file below are the example program to explain this


class Student

{

    var name:String?

}

var gulshan = Student(name:"Gulshan")

var mazeed = gulshan

mazeed.name = "Mazeed"

print(gulshan.name)

// Prints the name as Mazeed

print(mazeed.name)

//Prints the name as Mazeed



No comments:

Post a Comment