Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Creating Instances of Structs | Intro to Structs & Maps
Introduction to GoLang

Creating Instances of StructsCreating Instances of Structs

In the previous chapter, we learned how to define a structure. However, the definition serves as only a blueprint, specifying how data is stored in an instance of that structure.

An instance of a structure is essentially a variable with the structure as its data type. Since it's a variable, data can be stored and modified within it.

Consider the following example of the Person structure from the previous chapter:

go

index.go

We can create an instance of Person using the following syntax:

go

index.go

Note

In code, the structure must be defined before its instances are created.

How would you create an instance called stud1 of the following class:

Виберіть правильну відповідь

Все було зрозуміло?

Секція 6. Розділ 2
course content

Зміст курсу

Introduction to GoLang

Creating Instances of StructsCreating Instances of Structs

In the previous chapter, we learned how to define a structure. However, the definition serves as only a blueprint, specifying how data is stored in an instance of that structure.

An instance of a structure is essentially a variable with the structure as its data type. Since it's a variable, data can be stored and modified within it.

Consider the following example of the Person structure from the previous chapter:

go

index.go

We can create an instance of Person using the following syntax:

go

index.go

Note

In code, the structure must be defined before its instances are created.

How would you create an instance called stud1 of the following class:

Виберіть правильну відповідь

Все було зрозуміло?

Секція 6. Розділ 2
some-alt