Course Object Oriented Programming
Struct in C++
In this class, we will see how structs work in C++.
Structures in C++
The way to define structs in C++ is similar to the way to define them in C. However, C-structs do not allow the programmer to use much of the Object-Oriented Programming concepts.
These are the main differences between structs in C++ and C:
- To declare a variable, you don't need the name struct;
- Allows methods (actions that objects can perform);
- Allows inheritance;
- Allows more types of polymorphisms.
Definition of a Struct in C++
Very similarly to C, to define a struct in C++, it is done:
struct <name> {
// attributes and