公告

<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

统计

  • 随笔 - 9
  • 文章 - 13
  • 评论 - 3
  • 引用 - 0

常用链接

留言簿(1)

随笔分类

随笔档案

文章分类

文章档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜

boost---first day!

class  Test
{
public :
    Test(
const  std:: string  str);
    
~ Test();
    
///////////////////// //
     void  print();
private :    
    
const  std:: string  _str;
    
}
;


/* ++++++++++++++++++++++++++++++++++++++++ */
int  main( int  argc,  char *  argv[])
{
//     using namespace boost;
    typedef boost::shared_ptr < Test >  Ptr_Test;
    std::
string  str =   " what " ;
    std::vector
< Ptr_Test >  vtest;
    Ptr_Test test(
new  Test(str));
    Ptr_Test test1(test);

    test.
get () -> print();  // 调用Test::print()输出;

    vtest.push_back(test); 
// 于stl公用。。爽!
    vtest.push_back(test1);
    
////////////////////////////// /
    std::vector < std:: string >  _int;
    _int.push_back(
" 132 " );
    
int  i  =  boost::lexical_cast < int > ( " 123 " );  // 类型转换;很简单!
    cout  <<  i  <<  endl;
    
    
return   0 ;
}

/* +++++++++++++++++++++++++++++++++++++++++ */
Test::Test(
const  std:: string  str):_str(str)
{

}

// ---------------------------------
void  Test::print()
{
    cout 
<<   " the member str in Test: "   <<  _str.c_str()  <<  endl;
}

// ---------------------------------
Test:: ~ Test()
{

}


/*++++++++++++++++++++++++++++++++*/
crc生成校验码
/*++++++++++++++++++++++++++++++++*/
代码:
void Test_crc()
{
        
const char buf[5= {1,2,3,4,5};
        boost::crc_32_type fcrc32;
        fcrc32.process_bytes(buf, 
sizeof(buf));
        std::cout 
<< std::hex << std::uppercase << fcrc32.checksum() << std::endl;
            //输出结果为16进制大写的校验码
        getchar();
}

未完待续~~~(^O^)

posted on 2006-08-23 15:10 blues 阅读(140) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理