C++ Primer (5th Edition)

C++ Primer (5th Edition)

Stanley B. Lippman

Language: English

Pages: 976

ISBN: 0321714113

Format: PDF / Kindle (mobi) / ePub


Bestselling Programming Tutorial and Reference Completely Rewritten for the New C++11 Standard

 

Fully updated and recast for the newly released C++11 standard, this authoritative and comprehensive introduction to C++ will help you to learn the language fast, and to use it in modern, highly effective ways. Highlighting today’s best practices, the authors show how to use both the core language and its standard library to write efficient, readable, and powerful code.

 

C++ Primer, Fifth Edition, introduces the C++ standard library from the outset, drawing on its common functions and facilities to help you write useful programs without first having to master every language detail. The book’s many examples have been revised to use the new language features and demonstrate how to make the best use of them. This book is a proven tutorial for those new to C++, an authoritative discussion of core C++ concepts and techniques, and a valuable resource for experienced programmers, especially those eager to see C++11 enhancements illuminated.

 

Start Fast and Achieve More

  • Learn how to use the new C++11 language features and the standard library to build robust programs quickly, and get comfortable with high-level programming
  • Learn through examples that illuminate today’s best coding styles and program design techniques
  • Understand the “rationale behind the rules”: why C++11 works as it does
  • Use the extensive crossreferences to help you connect related concepts and insights
  • Benefit from up-to-date learning aids and exercises that emphasize key points, help you to avoid pitfalls, promote good practices, and reinforce what you’ve learned

 

Access the source code for the extended examples from informit.com/title/0321714113

 

C++ Primer, Fifth Edition, features an enhanced, layflat binding, which allows the book to stay open more easily when placed on a flat surface. This special binding method—notable by a small space inside the spine—also increases durability.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

that the parameter in check6 is also a const string&. Thus, a call to check6 must pass an argument of type string, which check6 will pass as the first argument to check_size. The second argument in arg_list (i.e., the third argument to bind) is the value 6. That value is bound to the second parameter of check_size. Whenever we call check6, it will pass 6 as the second argument to check_size: Click here to view code image string s = "hello"; bool b1 = check6(s); // check6(s) calls

resetting p has no effect on q, which became invalid when we deleted the memory to which p (and q!) pointed. In real systems, finding all the pointers that point to the same memory is surprisingly difficult. * * * Exercises Section 12.1.2 Exercise 12.6: Write a function that returns a dynamically allocated vector of ints. Pass that vector to another function that reads the standard input to give values to the elements. Pass the vector to another function to print the values that were read.

recognizing when we need to define them in the first place. * * * Warning Copy control is an essential part of defining any C++ class. Programmers new to C++ are often confused by having to define what happens when objects are copied, moved, assigned, or destroyed. This confusion is compounded because if we do not explicitly define these operations, the compiler defines them for us—although the compiler-defined versions might not behave as we intend. * * * 13.1. Copy, Assign, and

representation of floating-point values is unaffected. * * * Indicating Base on the Output By default, when we print numbers, there is no visual cue as to what notational base was used. Is 20, for example, really 20, or an octal representation of 16? When we print numbers in decimal mode, the number is printed as we expect. If we need to print octal or hexadecimal values, it is likely that we should also use the showbase manipulator. The showbase manipulator causes the output stream to

response. If not, or if the input starts with an n, the loop is exited. Otherwise the loop is repeated. Because the condition is not evaluated until after the statement or block is executed, the do while loop does not allow variable definitions inside the condition: Click here to view code image do { // . . . mumble(foo); } while (int foo = get_foo()); // error: declaration in a do condition If we could define variables in the condition, then any use of the variable would happen before the

Download sample

Download