c++笔记7STL标准模板库

文章目录


stl standard template library 标准模板库
util
c++ 集合-> java 集合

string

#include <string>
void main()
{
	string s1 = "craig david";
	string s2(" 7 days");
	string s3 = s1 + s2;

	cout << s3 << endl;
	
	//转c字符串
	const char* c_str = s3.c_str();
	cout << c_str << endl;

	//s1.at(2);
	//s1.length();


	system("pause");
}

容器

#include <vector>

void main()
{
	//动态数组
	//不需要使用动态内存分配,就可以使用动态数组
	vector<int> v;
	v.push_back(12);
	v.push_back(10);
	v.push_back(5);

	for (int i = 0; i < v.size(); i++)
	{
		cout << v[i] << endl;
	}

	system("pause");
}

猜你喜欢

转载自blog.csdn.net/fxjzzyo/article/details/84527746