Help Menu

Chapter 16 - Object-oriented Programming Foundations

Visual C++ 6: The Complete Reference
Chris H. Pappas and William H. Murray, III
  Copyright 1998 The McGraw-Hill Companies

Chapter 16: Object-oriented Programming Foundations
Overview
This chapter will discuss object-oriented terms and definitions. As you prepare to enter the world of object-oriented programming, you should know that except for your current version of the Microsoft Visual C++ compiler, no special hardware is required.
When a program is written and compiled into an executable format, an .EXE file is created. Take a moment to think about just what that means. In file type terms, it means that a *.EXE is a *.EXE is a *.EXE. In other words, no matter if the source file was interpreted (as in the case of the BASIC language), compiled (as in assembly language, Pascal, FORTRAN, C, and C++), or compiled and interpreted (as in Java), once the translator generated the final executable form, they all ran on the same microprocessor!
This means that regardless of the source syntax, all of the program’s instructions are translated down to machine language: adds, subtracts, compares, jumps, loops, and so on—native to the microprocessor. If you know assembly language, you already know just how close a language can be to the actual microprocessor’s native tongue. As a language becomes more “high-level,” you simply force the interpreter or compiler to do more work in getting your English-like statements translated to something the computer understands. And, in the case of all object-oriented languages, even more translation work is required.
However, the burden of work is on the translator. Since you do not buy a new computer to run object-oriented programs, object-oriented languages are inherently incapable of providing any additional microprocessor horsepower than, say, assembly language! Stop for a moment to ponder this last statement.
The real question to ask is “What is real different about object-oriented languages such as C++?” In a word packaging! Consider this simple analogy. For the purpose of argument, imagine a program that declares and uses 100 integer variables. Messy, yes, but structurally possible. Now, imagine that you are in an intro computer course and your instructor begins teaching the topic of arrays. Ah, you say, what a logical and syntactical way to clean up this mess of 100 hundred separate, stand-alone integer variables! However, you also know that the rewritten array version did not give your program any more horsepower—it just streamlined logical and syntactical efficiency. In a similar sense, that is all that object-oriented programming does.
Object-oriented programming languages streamline and repackage concepts you, as a programmer, already know! What are new are those language constructs unique to C and C++, not found in other programming languages, that form the foundational building blocks to C++’s object-oriented capabilities. For example, C’s keyword static is a non-object-oriented language feature. However, static can be used in object-oriented programs. If you are new to object-oriented design and syntax, your problem will not be learning how to repackage what you already know—such as how to write a function (called a member function or method in OOP terminology)—but rather how to incorporate C and C++’s new constructs in conjunction with the repackaging.
Here is one more fundamental concept you need to understand. You do not need to use object-oriented syntax to write a Windows 98 or NT application, and you can use object-oriented syntax to write DOS applications! Object-oriented syntax is a separate issue from what a program needs structurally to run under a multitasking operating system like Windows, or under the now fading command-line MS-DOS mode. Beginning OOPS and Windows programmers often view the two requirements as one entity.
More confusion is added to the mix by the product-specific recombinations of this packaging of “standard Windows syntax” used by companies. Using all of the objects available in the Visual C++ compiler package, for example, can be an overwhelming experience at first. To avoid this, Microsoft has preselected “standard” Windows objects and repackaged the already repackaged horsepower. Microsoft calls this double repackaging MFC (Microsoft Foundation Class) library.
With all of this information under your belt, sit back and relax. In this chapter you will see what you already know as a programmer become the underpinnings to object-oriented horsepower. They only thing standing in your way is terminology. Many of the procedural language fundamentals you already use have new names in an object-oriented world. For example, in this chapter you will learn how the C++ class type (an actual object-definition syntax/concept) is an outgrowth of the C struct type (a regular procedural language record-definition syntax/concept)!

Books24x7.com, Inc 2000 –  


Visual C++ 6(c) The Complete Reference
Visual Studio 6: The Complete Reference
ISBN: B00007FYGA
EAN: N/A
Year: 1998
Pages: 207

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