Structures (Struct)
Same syntax for both C and C++.
If you initialize with a value, all other properties will be initialized to 0.
Make sure not to confuse it with a Class, which is Object-Oriented Programming.
Use typedef
in front of struct to make your life easier.
- See typedef
Struct in C++
In C++, you don’t need the typedef word, and directly use the struct
- Also, you can just use the
{}
initializers
Class
vs. Struct
- Use
struct
when all you want is structured data, and - Use
class
es when you want methods, Inheritance, or generics
See Class