C++ Objects and Scope
Important Definitions Class Access and Visibility Encapsulation Unified Modeling Language (UML) Constructor Destructor Scope
Class Definitions A Class is a blueprint for an object. It holds a recipe for making/using an object
Access Specifies Items inside of a class can be set to be accessible only by objects of that class or by anyone A public member can be accessed (using an object of the class1) anywhere in a program that #includes the class definition file. A protected member can be accessed inside the definition of a member function of its own class, or a member function of a derived class. A private member is only accessible by member functions of its own class.
Encapsulation Encapsulation is the term used to describe how an object contains its own data and functions for manipulating that data. Encapsulation lets an object be 'self- sufficient'
Unified Modeling Language (UML) A graphical way of seeing a class and its associated data elements and methods/functions. Figure from course text
Constructors Every object when its created runs a 'constructor' function A class can have different constructors at the same time based on different needs
Destructors Every object when it is destroyed runs a 'destructor' function Destructors keep memory clean They can handle IO operations (closing files or ports)
Scope Scope™ is a mouthwash Scope is where variables and function exist in code. Something 'out of scope' can not be accessed or manipulated The main method of defining scope is { and }
In Summary Classes describe objects Classes show what is 'encapsulated' in an object All classes have constructors and destructors.