当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

    摘要: int main(int argc, char* argv[]) { string file_name; cout<<"please input the filename:"<<" "; cin>>file_name; ifstream infile(file_name.c_str()); if(!i......
    摘要: 我用ado控件的addnew方法添加一条记录填入数据并用update方法更新完毕。 然后用delete方法删除当前记录,可是会出现 -2147217864 "无法为更新行集定位:一些值可能已在最后读取后改变。"的错误,我还有绑定一个datagrid,一个combobox,五个textbox和一个datacombo,combobox,请各位高手帮帮忙,我很急!!!实在搞不......


使用Vector后,应该怎样处理后事

我在一个类A中用到了Vector  
  定义如下  
  typedef   std::vector   <   Pop   >   PopVector;  
  其中Pop是我用到的一个结构体,其中都是简单类型.  
   
  我在另一个类B中定义了一个A的实例,  
  用完后调用A的析构函数,在释放Vector时出错,

NO.1   作者: zhdleo

#include   <vector>  
   
  #if   _MSC_VER   >   1000  
  #pragma   once  
  #endif   //   _MSC_VER   >   1000  
   
  #if   _MSC_VER   >   1020       //   if   VC++   version   is   >   4.2  
  using   namespace   std;     //   std   c++   libs   implemented   in   std  
  #endif  
  typedef   vector<int>     INTVECTOR;  
  typedef   vector<   CString   >         STRINGVECTOR;  
  vector<   STRINGVECTOR   >   m_Table;  
  int   getLine(   int   i,     vector<CString>&   s){  
  if   (   iRet   !=   NO_ERR)  
  return   iRet;  
  else    
  {  
  s   =   m_Table.at(i);  
  return   NO_ERR;  
  }  
  }

NO.2   作者: JennyVenus

Example  
  //   adj_diff.cpp  
  //   compile   with:   /EHsc  
  //    
  //   Description   of   adjacent_difference(first,last,result)  
  //                                 adjacent_difference(first,last,result,binary_op):  
  //  
  //         Assigns   to   every   element   referred   to   by   iterator   i   in   the   range  
  //         [result   +   1,   result   +   (last   -   first))  
  //         a   value   correspondingly   equal   to  
  //         *(first   +   (i   -   result))   -   *(first   +   (i   -   result)   -   1)  
  //         or  
  //         binary_op(*(first   +   (i   -   result)),   *(first   +   (i   -   result)   -   1)).  
  //         Result   gets   the   value   of   *first.  
   
  #include   <iostream>  
  #include   <numeric>  
  #include   <functional>  
  #include   <vector>  
  #include   <iterator>  
   
  using   namespace   std;  
   
   
  typedef   vector   <   int   >   IntegerArray;  
  typedef   ostream_iterator   <   int,   char,   char_traits<char>   >   IntOstreamIt;  
   
  int   main   ()  
  {  
          //   an   ostream   iterator   that   outputs   an   int   to   cout   terminated  
          //   by   a   space  
          IntOstreamIt   itOstream(cout,"   ");  
   
          //   Initialize   the   array  
          //   Suppose   that   you   are   taking   a   trip   and   can   measure  
          //   the   miles   traveled   from   your   city   of   origin  
          //   to   the   city   you   are   traveling   through  
          IntegerArray   rgIA;  
          rgIA.push_back(5661);   //   San   Francisco   to   Berlin  
          rgIA.push_back(7456);   //   to   Cairo  
          rgIA.push_back(10995);   //   to   Calcutta  
          rgIA.push_back(17019);   //   to   Cape   Town  
          rgIA.push_back(24394);   //   to   Hong   Kong  
          rgIA.push_back(30376);   //   to   London  
          rgIA.push_back(35758);   //   to   Los   Angeles  
   
          //   Print   the   array  
          copy(rgIA.begin(),rgIA.end(),itOstream);  
          cout   <<   endl;  
   
          //   Suppose   that   you   now   want   the   distance   between   each  
          //   of   the   cities   that   you   traveled   to.   You   can   easily  
          //   find   it   with   adjacent_difference()  
          IntegerArray   rgDifferences(7);  
          IntegerArray::iterator   itDifferences   =   rgDifferences.begin();  
          adjacent_difference(rgIA.begin(),rgIA.end(),itDifferences);  
   
          //   Print   the   differences  
          //   Remember   that   the   first   item   in   the   differences   array   is  
          //   not   a   difference,   but   is   unused   space  
          cout   <<   "The   adjacent   differences   are:   ";  
          copy(rgDifferences.begin()+1,rgDifferences.end(),itOstream);  
          cout   <<   endl;  
   
          //   Suppose   that   you   now   want   to   know   which   adjacent   differences  
          //   are   greater.   If   you   have   [a,b,c],   you   would   like   [1,0]   if   a>b  
          //   and   b<=c.  
          //   You   are   using   less()   rather   than   greater()   because  
          //   adjacent_difference()   reverses   the   parameters.   For   example,  
          //   if   a   and   b   are   adjacent,   adjacent_difference()   calls  
          //   less(b,a).   See   the   explanation   at   the   top   of   this   file  
          //   for   a   more   exact   description.  
          IntegerArray   rgGT(6);  
          IntegerArray::iterator   itGT   =   rgGT.begin();  
          adjacent_difference(rgDifferences.begin()+1,  
                                                  rgDifferences.end(),  
                                                  itGT,  
                                                  less<int>());  
   
          //   Print   the   greater   thans  
          //   Remember   that   the   first   item   in   the   differences   array   is  
          //   not   a   difference,   but   is   unused   space  
          cout   <<   "Which   adjacent   distances   are   greater:"   <<   endl  
                    <<   "(If   you   have   [a,b,c],   then   you   have   [1,0]   if   a>b   and   b<=c)"  
                    <<   endl;  
          copy(rgGT.begin()+1,rgGT.end(),itOstream);  
          cout   <<   endl;  
  }  
  Output  
  5661   7456   10995   17019   24394   30376   35758    
  The   adjacent   differences   are:   1795   3539   6024   7375   5982   5382    
  Which   adjacent   distances   are   greater:  
  (If   you   have   [a,b,c],   then   you   have   [1,0]   if   a>b   and   b<=c)  
  0   0   0   1   1    
 


    摘要: 我现在有一张表a,结构如下: name null? type ----------------------------------------- -------- ----------------- docid not null varchar2(200) codeno not null varchar2(200) repno not null varcha......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE