cppreference
Built-in Types | Abstract Data Types |
---|---|
defined directly by C++ language | defined by standard libraty |
repersents computer hardware facilities | usually don't implemented by computer hardware |
e.g., int, array... | e.g., vector, string... |
std::string::npos //-1 /*初始化*/ string s(10, 'c'); //s: "cccccccccc" /*遍历*/ for(auto &c:s) //&引用 /*normal*/ s.size(); s.empty(); /*find*/ s.find(substr, pos=0); //return size_type /*子串*/ s.substr(pos,count); //return string /*string, char [], char**/ ... /*string,int*/ to_string((int)i); //<string> /*Algorithms*/ reverse(s.begin(),s.end());
/*Algorithms*/ vector<int>::iterator max = max_element(v.begin(),v.end()); reverse(v.begin(),v.end()); sort(v.begin(),v.end(),cmp()=NULL); stable_sort(v.begin(),v.end(),cmp()=NULL);