Linux下C++编程

26 篇文章 0 订阅

[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有关,后放的靠前。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值