Switching to Object-Oriented Programming
A Simula class consists of a header and a body. The header includes the class name and, if necessary, parameters and their declarations. The body houses local variables, procedures, and the core code (the lifeline). This structure is familiar to developers versed in C++, Java, Python, or similar languages. However, when introduced in the late 1960s, the concept of encapsulation was revolutionary.
Defining a Simple Class
The code snippet below outlines a simple class representing a two-dimensional point. The point comprises two integer attributes: the coordinates x and y. These attributes must be supplied when creating a new object of the class.
| | CLASS Point2d(x,y); INTEGER x,y; ... |
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