December 19, 2000

Forward Declaration of Classes and Structs

You can use the keywords class and struct in forward declarations interchangeably. For example: class X; // fwd declaration uses ‘class’X *p;struct X // definition uses ‘struct'{};void f(){ p=new X;}

Overcoming Debuggers’ Limitations

Many symbolic debuggers limit the length of symbols they can display. For example, the Visual C++ debugger can display strings that contain up to 255 characters. Suppose you have a

Covariant Template Parameters

Suppose you need to define a function that takes a vector object and performs certain operations on it. The function has to be generic, that is, it should handle all

Portable Locks

Sometimes you need to make sure that only one instance of the same application can run at any given time. Although every platform defines different locking schemes, you can use

Function Object Bases

To simplify the process of writing custom function objects, the Standard Library provides two classes that serve as base classes of such objects: std::unary_function and std::binary_function. Both are declared in

The remove_if() algorithm

The remove_if() algorithms (defined in the standard header ) has the following prototype: template ForwardIterator remove (ForwardIterator first, ForwardIterator last, Predicate pred); The first two arguments mark the sequence’s beginning

The remove() Algorithm

The Standard Library defines the std::remove() algorithm, which moves desired elements to the front of a container and returns an iterator pointing to the end of the sequence of the