OBJECT-ORIENTED PROGRAMMING


Object-Oriented Programming (OOP) is a central feature of Visual C++. At its core is the concept of grouping related code and data. This philosophy allows for the creation and use of self-contained objects that are highly organized, easy to understand, and easy to use.

Objects have several valuable features. They can store data and provide mechanisms for changing, retrieving, or performing operations on data after it is stored. Objects also can validate the information they receive, ensuring that a program works only with data that is valid. These features allow an application to be made of parts that are robust and reliable.

Although you might not have been aware that you were doing so, you have already worked extensively with objects. Consider the many controls that you have employed throughout this book. Whenever you have added one to your program, you have been instructing your program to make use of an object. The TextBox control, for instance, is an object that, when added to your program, gives it the ability to display and accept data in the form of text and numbers.

In Visual C++, objects can have methods, properties, and events. Methods allow the object to run code that might manipulate data or provide other functionality. Properties store data. Events allow the object to respond to specific events generated by Windows or your application. A button's Enabled property is an example of an object property, whereas the Show() method of MessageBox is an example of a method. You can see an example of an event in the code that results when you double-click a form or control.

One of the most powerful aspects of OOP is that you don't need to understand how an object works internally to be able to use it within your program. Rather, you just need to employ an object's interface—those properties, methods, and events that it makes available for use. As an example, consider the TextBox control again. You only have access to the properties, methods, and events that the .NET programmers at Microsoft have provided. This allows you to use the control without worrying about how it is put together. Internal details such as how the control's program code manages fonts, limits text to the extents of the TextBox, or controls the placement of each letter are details that you can safely ignore.




Microsoft Visual C++ 2005 Express Edition Programming for the Absolute Beginner 2006
Microsoft Visual C++ 2005 Express Edition Programming for the Absolute Beginner 2006
ISBN: 735615381
EAN: N/A
Year: 2005
Pages: 131

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net