Chapter 3
Classes
Section 2
Declaring and Defining a Class
Location data is a combination of latitudes and longitudes which are represented as float values. With such a representation, when the code needs to operate on a location, both the latitude and longitude will be provided as separate variables. To avoid the error, instead of using operations on two float types, we can define a Location type, which stores the location and provides the necessary operations to interact with it. Let us see how a class helps in combining data and operations.