容器分类及string分析

1 STL容器分类

1.1 顺序容器 sequence containers

  • array
  • vector
  • deque
  • list
  • forward-list 

1.2 关联容器 associative containers(红黑树实现)

  • set
  • multiset
  • map
  • multimap

1.3 无序容器 unordered containers (hash表实现)(非标准,也可以划分到关联容器)

  • hash_set
  • hash_multiset
  • hash_map
  • hash_multimap

2 string分析

2.1 string指向的内存空间在堆上(待证明)

#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;
}
发布了123 篇原创文章 · 获赞 31 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/qq_40794602/article/details/102990015
今日推荐