1. stable_partition: stable division and unstable division.
# Include <iostream> # include <algorithm> # include <vector> using namespace STD; struct student {char name [20]; int age ;}; ostream & operator <(ostream & OS, const student & S) {OS <"(" <S. name <"" <S. age <")"; return OS;} bool agecom (student & S) {return S. age <30 ;}int main (INT argc, char * argv []) {student STU [] ={{ "zhangsan", 29 },{ "Lisi", 57 }, {"wangwu", 49 },{ "zhaoliu", 27 }}; copy (Stu, Stu + 4, ostream_iterator <student> (cout ,"")); cout <Endl; // an unstable division vector <student> VEC (Stu, Stu + 4); partition (VEC. begin (), VEC. end (), agecom); copy (VEC. begin (), VEC. end (), ostream_iterator <student> (cout, ""); cout <Endl; // stable division vector <student> vec2 (Stu, Stu + 4 ); stable_partition (vec2.begin (), vec2.end (), agecom); copy (VEC. begin (), VEC. end (), ostream_iterator <student> (cout, ""); cout <Endl ;}
2. Trace macro
Trace is not a function but a macro. It is used to generate messages from your program in the output window of the debugger.
It works only in debug mode. It is useless in release mode. You can regard it as a printf statement, but this statement automatically disappears in release mode.
3. STL containers
The method in 3.1 list is as follows:
Updating...