Understanding object-oriented principles
While OOP is nearly ubiquitous in programming literature and discourse, it comes in many different styles and flavors. In this section, we'll briefly review the core principles of OOP in C++ so that we have a basis from which to examine Rust's implementation of these same principles.
The term object-oriented programming was coined by Alan Kay, designer of the Smalltalk programming language, in the 1960s. While the Smalltalk OOP model is of historical interest, it differs in several ways from the model chosen by C++ and many of its successors. As a result, OOP can be difficult to define precisely. Nevertheless, most modern discussions converge on a small set of core principles, which we'll examine in this section.
Abstracting behavior and encapsulating data
The focus of OOP is, of course, objects. An object is a collection of states that exposes a public interface to other objects in some form. Objects, in C++ and...