standard template library 标准模板库,相当于java中的util
字符串
#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);
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");
}
网友评论