C++ Neural Networks and Fuzzy Logic
by Valluru B. Rao
MTBooks, IDG Books Worldwide, Inc.
ISBN: 1558515526 Pub Date: 06/01/95
Previous Table of Contents Next
Chapter 2
C++ and Object Orientation
Introduction to C++
C++ is an object−oriented programming language built on the base of the C language. This chapter gives you
a very brief introduction to C++, touching on many important aspects of C++, so you would be able to follow
our presentations of the C++ implementations of neural network models and write your own C++ programs.
The C++ language is a superset of the C language. You could write C++ programs like C programs (a few of
the programs in this book are like that), or you could take advantage of the object−oriented features of C++ to
write object−oriented programs (like the backpropagation simulator of Chapter 7). What makes a
programming language or programming methodology object oriented? Well, there are several indisputable
pillars of object orientation. These features stand out more than any other as far as object orientation goes.
They are encapsulation, data hiding, overloading, polymorphism, and the grand−daddy of them all:
inheritance. Each of the pillars of object−orientation will be discussed in the coming sections, but before we
tackle these, we need to answer the question, What does all this object−oriented stuff buy me ? By using the
object−oriented features of C++, in conjunction with Object−Oriented Analysis and Design(OOAD), which is
a methodology that fully utilizes object orientation, you can have well−packaged, reusable, extensible, and
reliable programs and program segments. It’s beyond the scope of this book to discuss OOAD, but it’s
recommended you read Booch or Rumbaugh to get more details on OOAD and how and why to change your
programming style forever! See the reference section in the back of this book for more information on these
readings. Now let’s get back to discussing the great object−oriented features of C++.
Encapsulation
In C++ you have the facility to encapsulate data and the operations that manipulate that data, in an appropriate
object. This enables the use of these collections of data and function, called objects , in programs other than
the program for which they were originally created. With objects, just as with the traditional concept of
subroutines, you make functional blocks of code. You still have language−supported abstractions such as
scope and separate compilation available. This is a rudimentary form of encapsulation. Objects carry
encapsulation a step further. With objects, you define not only the way a function operates, or its
implementation, but also the way an object can be accessed, or its interface. You can specify access
differently for different entities. For example, you could make function do_operation() contained inside
Do'stlaringiz bilan baham: |