.erase()

The .erase() method removes an element by it’s key from a map.

Syntax

mapName.erase(key);

The key is the element to be erased.

Codebyte Example

The following codebyte example uses .erase() to remove an element from the fields map:

Code
Output
Loading...
Looking to contribute?

Learn C++ on Codecademy