9.1. IntroductionIn the preceding chapters, we introduced the basic concepts and terminology of object-oriented programming (OOP) in Visual Basic. This chapter takes a deeper look at classes. We introduce class scope and discuss how it affects where class members can be accessed. We demonstrate that constructors can be overloaded to allow clients to initialize objects of a class in several ways. We discuss how partial classes enable one class to span multiple source-code files. We explain compositiona capability that allows a class to have references to objects of other classes as members. We show how to use the Me reference to refer to the current object's members. The chapter presents garbage collection and discusses how it eliminates most "memory leaks." In addition, we discuss Shared class variables that are shared among all objects of a class. We then present the differences between constant members created with Const and ReadOnly. Finally, we show how to use the Object Browser to discover the capabilities of the classes in the Framework Class Library (FCL). Chapters 10 and 11 introduce inheritance and polymorphism, respectivelytwo key OOP technologies. |