ECS 30 Lecture Notes - Lecture 10: Linked List
![](https://new-preview-html.oneclass.com/rwz4BW6gGqbajYlpwVlrmvLP3edVpolX/bg1.png)
5/30/2018 lecture
Structures
Basic example
- Struct creates new data type
o Collection of one or variables
o Possibly of different types
o Grouped together under unified name
- Ideal to describe complex objects
o Group related variables as a unit
- Access to structure members with “.”
o Highest precedence
Initialization
- Initialization with ordered list of initializers
- Copy by copy
- By function
o No conflict in names
o Returns byte copy of object
Multi-level structure
Function (by copy)
*c.dir → it will fail
The “.” has high priority → C will think its an address
Parenthesis around *c
- (*c).dir → this will work
- Only addresses of structure is passed
- Much better for memory footprint and performance
- Another option: Use arrow operator
(*c).deg
- first dereference pointer to get the object
- Second, access to member
- Otherwise it wont work
Reference:
- Lng
- Lng.deg
p_lng
find more resources at oneclass.com
find more resources at oneclass.com