Classes and Objects
As described above, a class describes what data an object can hold and what it can do with that data. For example, consider we have to create a Book
object and store the data mentioned in the example above. But first, we have to specify what a Book
object looks like, i.e. declare a Book
class.
In the class declaration, we specify the following:
the variables that will store data (
attributes
)a function that gets called whenever we create a new object (
constructor
)function(s) that can access the attributes and use the values for processing (
methods
)