Declaring and Defining a Class
A class is a way to combine data and operations together to create new types that can be used to represent complex concepts.
Basic types can be composed to create more meaningful abstractions. For example, location data is composed of latitude and longitude coordinates, which are represented as float values. With such a representation, when our code needs to operate on a location, we would have to provide both the latitude and longitude as separate variables. This is error-prone, as we might forget to pass one of the two variables, or we could provide them in the wrong order.
Additionally, computing the distance between two coordinates is a complex task and we don't want to write the same code again and again. It becomes even more difficult when we use more complex objects.
Continuing our example on Coordinates, instead of using operations on two float types, we can define a type, which stores the location and provides the necessary operations to interact with...