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^)
