C++ notes 7STL standard template library

Article Directory


stl standard template library
util
c++ collection -> java collection

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");
}

container

#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");
}

Guess you like

Origin blog.csdn.net/fxjzzyo/article/details/84527746