Table of Contents

inherit map

Maps can be inherited. For example, to cache a bunch of “foo” objects, one can use

class fooCache : public map<string, foo>
{
  public:
    ~fooCache();
    // more functions to manipulate cache
};

tags | derive a c++ class from a map

checklist when factoring out a function

1. Add a semicolon, remove class name in the new function's declaration.

2. Add a return statement in the new function's definition if the function is supposed to return a value.

possible fixes to common g++ errors

# error: XXX does not name a type

If XXX is declared by auto keyword, add -std=c++11 to the compilation command.

Tested on g++ 4.7.1

function declarations

Information that is available only in function declarations but not in the function definitions

  1. Whether a function is static, virtual etc.,
  2. If there is a default value supplied to the argument(s).

To replace all occurrences of a character in a string

See minastaros solution in http://stackoverflow.com/questions/2896600/how-to-replace-all-occurrences-of-a-character-in-string

Reference

Type of iterators

The vector class supports a random access iterator, the most general kind. The list container only supports bidirectional iterators.

Complexity of operations