Andrew Koenig : Accelerated C
Login/Nick :

Heslo :

<   >Október 2026
PoUtStŠtPiSoNe
   1234
56789
10
11
12131415161718
19202122232425
262728293031 
    3678 : Andrew Koenig - Accelerated C++

    Andrew Koenig
    Accelerated C++

    Náučná pre dospelých
    výpočtová technika
    Jazyk:anglický
    336 strán
    Nakladateľ : Addison - Wesley
    Rok vydania : 2014
    V knižnici od : 17.8.2022
    Výpožičiek : 0
    Stav :

    Výška/šírka : 23.5x18.6 cm
    This is a first-rate introductory book that takes a practical approach to solving problems using C++. It covers a much wider scope of C++ programming than other introductory books I've seen, and in a surprisingly compact format. -Dag Bruck, founding member of the ANSI/ISO C++ committee The authors present a clear, cogent introduction to C++ programming in a way that gets the student writing nontrivial programs immediately. -Stephen damage, Sun Microsystems, Inc., and chair of the ANSI C++ committee Anyone reading just this one book and working through the examples and exercises will have the same skills as many professional programmers. -Jeffrey D. Oldham, Stanford University Why is Accelerated C++ so effective? Because it • Starts with the most useful concepts rather than the most primitive ones: You can begin writing programs immediately. • Describes real problems and solutions, not just language features: You see not only what each feature is, but also how to use it. • Covers the language and standard library together: You can use the library right from the start. The authors proved this approach in their professional-education course at Stanford University, where students learned how to write substantial programs on their first day in the classroom. Whether you are eager to get started writing your first C++ programs, or you are already using C++ and seeking deeper understanding, the authors' unique approach and expertise make Accelerated C++ an indispensable addition to your library. Andrew Koenig is a member of the Large-Scale Programming Research Department at AT&T's Shannon Laboratory, and the Project Editor of the C++ standards committee. A programmer for more than 30 years, 15 of them in C++, he has published more than 150 articles about C++, and speaks on the topic worldwide. He is the author of C Traps and Pitfalls and co-author of Ruminations on C++. Barbara E. Moo is an independent consultant with 20 years' experience in the software field. During her nearly 15 years at AT&T, she worked on one of the first commercial products ever written in C++, managed the company's first C++ compiler project, and directed the development of AT&T's award-winning WorldNet Internet service business. She is co-author of Ruminations on C++ and lectures worldwide.
    ÚRYVOK :
    20 Looping and counting Chapter 2 enclosed in { }. If the statement is just an ordinary statement, it will end with a semicolon of its own, so there's no need for another one. If it is a block, the block's } marks the end of the statement, so again there's no need for a semicolon. Because a block is a sequence of statements enclosed by braces, we know from §0.7/5 that a block is a scope. The while begins by testing its condition, which is an expression that appears in a context where a truth value is required. The expression r ! = rows is an example of a condition. This example uses the inequality operator, !=, to compare r and rows. Such an expression has type bool, which is a built-in type that represents truth values. The two possible values of type bool are true and false, with the obvious meanings. The other new facility in this program is the last statement in the while body, which is The ++ is the increment operator, which has the effect of incrementing—adding 1 to—the variable r. We could have written r = r + 1; instead, but incrementing an object is so common that a special notation for doing so is useful. Moreover, as we shall see in §5.1.2/79, the idea of transforming a value into its immediate successor, in contrast with computing an arbitrary value, is so fundamental to abstract data structures that it deserves a special notation for that reason alone. 2.3.2 Designing a while statement Determining exactly what condition to write in a while statement is sometimes difficult. Similarly, it can be hard to understand precisely what a particular while statement does. It is not too hard to see that the while statement in §2.3/19 will write a number of output rows that depends on the value of rows, but how can we be confident that we know exactly how many rows the program will write? For example, how do we know whether the number will be rows, rows - 1, rows + 1, or something else entirely? We could trace through the while by hand, noting the effect of each statement's execution on the state of the program, but how do we know that we haven't made a mistake along the way? There is a useful technique for writing and understanding while statements that relies on two key ideas—one about the definition of a while statement, and the other about the behavior of programs in general. The first idea is that when a while finishes, its condition must be false—otherwise the while wouldn't have finished. So, for example, when the while in §2.3/19 finishes, we know that r ! = rows is false and, therefore, that r is equal to rows. The second idea is that of a loop invariant, which is a property that "we assert will be true about a while each time it is about to test its condition. We choose an invariant that we can use to convince ourselves that the program behaves as we intend, and we write the program so as to make the invariant true at the proper times. Although the invariant is not part of the program text, it is a valuable intellectual tool for designing programs. Every useful while statement that we can imagine has an invariant associated with it. Stating the invariant in a comment can make a while much easier to understand.