Swift Program to Create a Structure Within Structure

You are currently viewing Swift Program to Create a Structure Within Structure

Swift program to create a structure within structure

// Swift program to create structure within structure

import Swift

struct Strct1 {
    struct Strct2 {
        var num2: Int=0
    }

    var num1: Int=0
    var str2=Strct2()
}

var str = Strct1()

str.num1        = 10
str.str2.num2   = 20

print(str.num1)
print(str.str2.num2)

Output

10
20

...Program finished with exit code 0
Press ENTER to exit console.

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply