Skip to main content Accessibility help
×
Hostname: page-component-5c6d5d7d68-wp2c8 Total loading time: 0 Render date: 2024-08-10T09:21:59.775Z Has data issue: false hasContentIssue false

Chapter 4 - Classes

Published online by Cambridge University Press:  06 July 2010

Michael McMillan
Affiliation:
Pulaski Technical College, Arkansas
Get access

Summary

This chapter introduces the class, the primary means of implementing OOP in VB.NET. The class framework provides the programmer with many techniques for exploiting the three main principles of OOP—encapsulation, inheritance, and polymorphism.

Classes are somewhat similar to structures in that they allow you to combine data members and methods in the same unit. Classes, though, are much more powerful than structures because they have many more tools available to them. These tools include constructor methods for creating new objects and the capabilities of having multiple methods with the same name and inheriting the definition of one class in another class.

This chapter begins with an overview of class construction, followed by the step-by-step creation of a class, and finally ending with several more examples of creating and using classes. The next few chapters in the book will explore many of the topics we introduce in this chapter.

BUILDING A CLASS

Class construction follows naturally from a well-designed ADT. There are some modifications we'll have to make to our ADT design to incorporate some concepts found in classes but not in structures. Still, a complete ADT makes building a class much easier than if you start from scratch.

The Class Heading

Like a structure, a class definition begins with its heading. The heading of a class consists of an access modifier, the reserved word Class, and a name for the class.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2004

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Classes
  • Michael McMillan, Pulaski Technical College, Arkansas
  • Book: Object-Oriented Programming with Visual Basic.NET
  • Online publication: 06 July 2010
  • Chapter DOI: https://doi.org/10.1017/CBO9780511734861.005
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Classes
  • Michael McMillan, Pulaski Technical College, Arkansas
  • Book: Object-Oriented Programming with Visual Basic.NET
  • Online publication: 06 July 2010
  • Chapter DOI: https://doi.org/10.1017/CBO9780511734861.005
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Classes
  • Michael McMillan, Pulaski Technical College, Arkansas
  • Book: Object-Oriented Programming with Visual Basic.NET
  • Online publication: 06 July 2010
  • Chapter DOI: https://doi.org/10.1017/CBO9780511734861.005
Available formats
×