Herb Schildt's C++ Programming Cookbook

Herb Schildt's C++ Programming Cookbook

Herbert Schildt

Language: English

Pages: 509

ISBN: 007148860X

Format: PDF / Kindle (mobi) / ePub

Herb Schildt's C++ Programming Cookbook

Herbert Schildt

Language: English

Pages: 509

ISBN: 007148860X

Format: PDF / Kindle (mobi) / ePub


Your Ultimate "How-To" Guide to C++ Programming!

Legendary programming author Herb Schildt shares some of his favorite programming techniques in this high-powered C++ "cookbook." Organized for quick reference, each "recipe" shows how to accomplish a practical programming task. A recipe begins with a list of key ingredients (classes, functions, and headers) followed by step-by-step instructions that show how to assemble them into a complete solution. Detailed discussions explain the how and why behind each step, and a full code example puts the recipe into action. Each recipe ends with a list of options and alternatives that suggest ways to adapt the technique to fit a variety of situations. Whether you're a beginner or an experienced pro, you'll find recipes that are sure to satisfy your C++ programming appetite!

Topics include:
String Handling • Standard Template Library (STL) Containers • Algorithms • Function Objects • Binders • Negators • Adaptors • Iterators • I/O • Formatting Data

Learn how to:

  • Tokenize a null-terminated string
  • Create a search and replace function for strings
  • Implement subtraction for string objects
  • Use the vector, deque, and list sequence containers
  • Use the container adaptors stack, queue, and priority_queue
  • Use the map, multimap, set, and multiset associative containers
  • Reverse, rotate, and shuffle a sequence
  • Create a function object
  • Use binders, negators, and iterator adapters
  • Read and write files
  • Use stream iterators to handle file I/O
  • Use exceptions to handle I/O errors
  • Create custom inserters and extractors
  • Format date, time, and numeric data
  • Use facets and the localization library
  • Overload the [ ], ( ), and -> operators
  • Create an explicit constructor
  • And much, much more

Write Great Code, Volume 1: Understanding the Machine

C++ Application Development with Code::Blocks

Moving To The Cloud: Developing Apps in the New World of Cloud Computing

Holub on Patterns: Learning Design Patterns by Looking at Code

Cocoa Recipes for Mac OS X (2nd Edition)

Beginning Database Design: From Novice to Professional (2nd edition)

 

 

 

 

 

 

 

 

 

 

 

are defined the parameterized manipulators specified by Standard C++. If you examine this header, you will probably see a more sophisticated approach, which utilizes templates and possibly complex macros. You could use the approach shown in that header to create your own parameterized manipulators that integrate with the class types defined by that header. However, because the classes in are implementation-specific, they may (probably will) differ between compilers. The approach used by

array. The version developed here uses a different approach. Called dyn_safe_array, it dynamically allocates memory for the array and stores only a pointer to that memory. This has the advantage of making the safe-array objects smaller—much smaller in some cases. This makes them more efficient when they are passed to functions, for example. Of course, it takes a bit more work to implement a safe array that uses dynamic memory, because both a copy constructor and an overloaded assignment operator

constructors recipe for using template specification ptr_fun( ) pointer-to-function adaptor push( ) push_back( ) push_front( ) push_heap( ) algorithm comparison function version Put pointer put( ) defined by money_put defined by num_put defined by time_put used with facets putback( ) putc( ) Q queue container adaptor constructor and list recipe for using template specification header R RandIter random_shuffle( ) algorithm rbegin( ) rdstate( ) to detect

statement being evaluated (which takes time), it does not streamline your program’s performance. As a general rule, exceptions offer a better alternative in this type of situation. To read unformatted, binary information from a file, see Read Unformatted Binary Data from a File. To read formatted data from a file, use ifstream. (See Read Formatted Data from a Text File.) Read Unformatted Binary Data from a File The recipe Read Formatted Data from a Text File described how to read

use the default constructor, then you will need to link a file to the fstream instance after it is constructed by calling open( ). The version defined by fstream is shown here: void open(const char *fname, ios::openmode mode = ios::in | ios::out) It opens the file specified by fname with the mode specified by mode. Notice that, like the fstream constructor, mode defaults to ios::in | ios::out. Therefore, the file is automatically opened for read/write operations when mode defaults. Before

Download sample

Download