[username@localhost cpp_stl]$ vi stl_main.cpp
1 #include <iostream>
2 #include <algorithm>
3 using namespace std;
4
5 const int SIZE = 100;
6 int iarray[SIZE];
7
8 int main()
9 {
10 iarray[20] = 50;
11 int *ip = find(iarray, iarray + SIZE, 50);
12 if(ip == iarray + SIZE)
13 cout << "50 not found in array" << endl;
14 else
15 cout << *ip << "found in array" << endl;
16 return 0;
17 }
18
~
~
~
~/cpp_stl/stl_main.cpp[POS=14,8][77%]30/06/14 - 10:26
[username@localhost cpp_stl]$ g++ -Wall -c stl_main.cpp [username@localhost cpp_stl]$ ls
stl_main.cpp stl_main.o
[username@localhost cpp_stl]$ g++ -o stl_main stl_main.o
[username@localhost cpp_stl]$ ls
stl_main stl_main.cpp stl_main.o
[username@localhost cpp_stl]$ ./stl_main
50found in array
退出GDB:q。
GDB调试程序:gdb 程序名。
[username@localhost cpp_stl]$ vi outiter.cpp
[username@localhost cpp_stl]$ g++ -g -Wall -o outiter outiter.cpp
[username@localhost cpp_stl]$ ls
outiter outiter.cpp stl_main stl_main.cpp stl_main.o
[username@localhost cpp_stl]$ gdb outiter
front_inserter创建一个使用push_front的迭代器。
front_inserter在头部先前插入,看起来像是倒序粘贴的,这与push_front有关,后放的靠前。