Skip to content

Instantly share code, notes, and snippets.

@RklAlx
Created November 4, 2013 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RklAlx/7305482 to your computer and use it in GitHub Desktop.
Save RklAlx/7305482 to your computer and use it in GitHub Desktop.
std::map
#include <map>
#include <string>
using std::map;
using std::string;
class CTeste
{
public:
CTeste(){}
~CTeste(){}
};
int main()
{
map<string,CTeste> my_map;
// If "Teste" exists, my_teste will point to that object.
// If "Teste" does not exist, map wil call the default constructor of CTeste and return the newly created object
CTeste& my_teste = my_map["Teste"];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment