Download Designing Components with the C++ STL, Third Edition, Ulrich PDF

Read Online or Download Designing Components with the C++ STL, Third Edition, Ulrich Breymann PDF

Best programming: programming languages books

Fortran 90 for Fortran 77 programmers

The luck of Fortran because the foremost programming language within the box of clinical and numerical computing is due, partly, to its regular evolution. Following the ebook of criteria in 1966 and 1978, the committee liable for their improvement, X3J3, labored at the side of an ISO committee to increase a customary appropriate to be used within the 1990's and past.

Additional info for Designing Components with the C++ STL, Third Edition, Ulrich Breymann

Example text

A short example shows its use. A pointer to a function is initialized with the sine function. Subsequently, the sine of an angle is called both via the function pointer and via a function object generated with ptr_fun(). 1 Namespaces In order to avoid any name clashes, nearly all sample classes in the book are in namespace br_stl. In files with sample main()-programs, often using namespace std; is used. All other programs use qualified names like in std::cout << std::endl; instead of cout << endl;.

The functors returned by the functions bind1st() and bind2nd() are of the type binder1st and SOME CONVENTIONS 27 binder2nd . In an application such as the one above, the types usually do not appear explicitly (class definition in header ). ptr_fun This overloaded function transforms a pointer to a function into a functor. As an argument, it has a pointer to the function which can have one or two parameters. The function returns a function object which can be called in the same way as the function.

Insertion or deletion of an element somewhere in the middle takes a time proportional to the number of elements that have to be shifted, thus, O(n) for n vector elements. It should be noted that iterators previously pointing to elements of the vector become invalid when the elements in question are shifted by the insertion or deletion. This also applies when the available space of the vector becomes insufficient for insert() and new space is allocated. The reason for this is that after allocation of new, larger memory space all elements are copied into the new space and therefore all old positions are no longer valid.

Download PDF sample

Rated 4.89 of 5 – based on 10 votes