.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...

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn C++ on Codecademy