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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章