.erase()

Published May 10, 2022Updated Dec 21, 2022
Contribute to Docs

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:

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn C++ on Codecademy