14 lines
846 B
HTML
14 lines
846 B
HTML
<p>
|
|
Structs are another way to define datatypes. They allow you to arange other datatypes into a specific <b>data layout</b>
|
|
to form your new data type. Imagine you want to write a program, which does some calculations with vectors.
|
|
Instead of using 3 variables for each vector, or a 3 dimentional array, you could have a single datatype for a vector.
|
|
</p>
|
|
<p>
|
|
You then could pass this single vector-type to functions and if you want to access certain <b>members</b>, you can give them convinient names.
|
|
To access the x component of the vector, you use the .-operator like this: <it>vector.x</it>.
|
|
A struct is declared just like a enum. But, instead of names, you declare members with types.
|
|
</p>
|
|
<p>
|
|
Your task is to define a struct position, which holds the 2d coordinates of the circle and then finish the PrintPos function.
|
|
</p>
|