Creating an Object
Using OOP is a two-step process. The first—defining a class—you just did when you wrote the HtmlTemplate class. The second step is to make use of that class by creating an object (or a class instance).
Going back to my Human class analogy, an instance of this class may be called Jude. Jude's attributes are a gender of male, a height of about 40 inches, a weight of 35 pounds, and a birth date of November 15, 1998. Jude is one instance of the Human class and, as you may have noticed, is also a child. A second instance, Kelsey, has a female gender, a height of nearly 5 feet, a weight of 75 pounds, and a birth date of April 11, 1992. Both Jude and Kelsey are separate objects derived from the same class.
Creating an object is remarkably ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access