Container classification and string analysis

1 STL container classification

1.1 Sequence containers

  • array
  • vector
  • and
  • list
  • forward-list 

1.2 associative containers (implemented by red and black trees)

  • set
  • multiset
  • map
  • multimap

1.3 Unordered containers (hash table implementation) (non-standard, can also be divided into associated containers)

  • hash_set
  • hash_multiset
  • hash_map
  • hash_multimap

2 string analysis

2.1 The memory space pointed to by string is on the heap (to be proved)

#include<iostream>
using namespace std;

int main()
{
	string a = "i am a handsome boy";
	string b = "i am a handsome boy";

	printf("%p\n", a.c_str());  //string.c_str() 返回的是一个 const char *
	printf("%p\n", b.c_str());
    //上述两行代码打印的地址不一样
	return 0;
}

 

Published 123 original articles · praised 31 · 90,000 views +

Guess you like

Origin blog.csdn.net/qq_40794602/article/details/102990015
Recommended