Introduction to objects The genesis of the computer revolution was in a machine. The genesis of our programming languages thus tends to look like that machine. But computers are not so much machines as they are mind amplification tools (“bic Citeste tot ...
Dimensiune
Design patterns
Design patterns “ . describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it th Citeste tot ...
Dimensiune
Exception handling
Exception handling Improved error recovery is one of the most powerful ways you can increase the robustness of your code.[BE1] Unfortunately, it’s almost accepted practice to ignore error conditions, as if we’re in a state of denial abo Citeste tot ...
Dimensiune
Function overloading & default arguments
Function overloading & default arguments One of the important features in any programming language is the convenient use of names. When you create an object (a variable), you give a name to a region of storage. A function is a name for Citeste tot ...
Dimensiune
Run-time type identification
Run-time type identification Run-time type identification (RTTI) lets you find the exact type of an object when you have only a pointer or reference to the base type. This can be thought of as a “secondary” feature in C++, a pragmatism to he Citeste tot ...
Dimensiune
Multiple inheritance
Multiple inheritance The basic concept of multiple inheritance (MI) sounds simple enough. [[[Notes: 1. Demo of use of MI, using Greenhouse example and different company’s greenhouse controller e Citeste tot ...
Dimensiune
Inline functions
Inline functions One of the important features C++ inherits from C is efficiency. If the efficiency of C++ were dramatically less than C, there would be a significant contingent of programmers who couldn’t justify its use. In C, one of the wa Citeste tot ...
Dimensiune
STL Algorithms
STL Algorithms The other half of the STL is the algorithms, which are templatized functions designed to work with the containers (or, as you will see, anything that can behave like a container, including arrays and string objects). The STL w Citeste tot ...
Dimensiune
Making & using objects
Making & using objects This chapter will introduce enough C++ syntax and program construction concepts to allow you to write and run some simple object-oriented programs. In the subsequent chapter we will cover the basic syntax of C and C++ Citeste tot ...
Dimensiune
The C in C++
The C in C++ Since C++ is based on C, you must be familiar with the syntax of C in order to program in C++, just as you must be reasonably fluent in algebra in order to tackle calculus. If you’ve never seen C before, this chapter will give yo Citeste tot ...
Dimensiune
Strings
Strings [1]One of the biggest time-wasters in C is character arrays: keeping track of the difference between static quoted strings and arrays created on the stack and the heap, and the fact that sometimes you’re passing around a char* and some Citeste tot ...
Dimensiune
Inheritance & composition
Inheritance & composition One of the most compelling features about C++ is code reuse. But to be revolutionary, you need to be able to do a lot more than copy code and change it. That’s the C approach, and it hasn’t worked very well. As w Citeste tot ...
Dimensiune
Introduction to templates
Introduction to templates Inheritance and composition provide a way to reuse object code. The template feature in C++ provides a way to reuse source code. Although C++ templates are a general-purpose programming tool, when they were introduce Citeste tot ...
Dimensiune
Polymorphism & virtual functions
Polymorphism & virtual functions Polymorphism (implemented in C++ with virtual functions) is the third essential feature of an object-oriented programming language, after data abstraction and inheritance. It provides another dimension of Citeste tot ...
Dimensiune
Coding style
Coding style This appendix is not about indenting and placement of parentheses and curly braces, although that will be mentioned. This is about the general guidelines used in this book for organizing the code listings. Although many of these Citeste tot ...
Dimensiune
References & the copy-constructor
References[BE1] & the copy-constructor References are a C++ feature that are like constant pointers automatically dereferenced by the compiler. Although references also exist in Pascal, the C++ version was taken from the Algol lan Citeste tot ...
Dimensiune
Maintaining system integrity
Maintaining system integrity The canonical object form An extended canonical form Dynamic aggregation The examples we’ve seen so far are illustrative, but fairly simple. It’s useful to see an example that has more complexity so you Citeste tot ...
Dimensiune
Templates in depth
Templates in depth Nontype template arguments Here is a random number generator class that always produces a unique number and overloads operator( ) to produce a familiar function-call syntax: //: C19:Urand.h // Unique ran Citeste tot ...
Dimensiune
Recommended reading
Recommended reading C Thinking in C: Foundations for Java & C++, by Chuck Allison (a MindView, Inc. Seminar on CD ROM, 1999, available at http://www.MindView.net). A course including lectures and slides in the foundations of the C Langua Citeste tot ...
Dimensiune
Name control
Name control Creating names is a fundamental activity in programming, and when a project gets large the number of names can easily be overwhelming. C++ allows you a great deal of control over both the creation and visibility of names, where sto Citeste tot ...