Like classes, structures also group together properties used to represent an object. They can also contain methods that do specific tasks.
You can also create instances of a structure. Remember the Animal class you created? You can also use a structure to accomplish the same thing. There are differences between classes and structures though, and you will learn more about those later.
Here's what a structure declaration looks like:
struct structName {
property1
property2
property3
method1() {
code
}
method2(){
code
}
}
Let's look at how to work with structures. You'll learn how to declare structures, create instances based on the structure declaration, and how to manipulate them. You'll start by creating a structure declaration.