iT邦幫忙

DAY 30
17

C++ 指標 30日系列 第 26

C++ 指標 30日(30)

衝啊!pointer!


尾聲

早說過C++的指標不好搞,相信有跟到這兒的邦友一定也能夠認同,但話說回來,若是指標能學得好,才能說掌握了這語言,不僅如此,這也是Linux作業系統的核心語言,所以有人也說C++語言是系統程式語言,除此之外,它也是撰寫網路,通訊及嵌入式程式的最常用語言。

最後,謝謝邦友們長期以來的支持與鼓勵,happy coding!


上一篇
C++ 指標 30日(29)
系列文
C++ 指標 30日26
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中
0
鐵殼心
iT邦高手 1 級 ‧ 2013-10-15 11:37:04

沙發
拍手

ted99tw iT邦高手 1 級 ‧ 2013-10-15 11:41:44 檢舉

恭喜沙發組完成使命~灑花

總裁 iT邦好手 1 級 ‧ 2013-10-15 13:26:38 檢舉

哈哈沙發

0
CalvinKuo
iT邦大師 7 級 ‧ 2013-10-15 11:44:40

恭喜泰大完成鐵人賽。
開心灑花拍手

0
海綿寶寶
iT邦大神 1 級 ‧ 2013-10-15 11:51:44

看了 30 天
我還是一試就倒
倒

以下這個到底要傳什麼鬼進去呀
搖頭

<pre class="c" name="code">
int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));

SQLite API

看更多先前的回應...收起先前的回應...

void(*)(void*)

這真的是要給人看的嗎
疑惑

總裁 iT邦好手 1 級 ‧ 2013-10-15 13:25:41 檢舉

這就是個二維不知指到啥的陣列,前面兩個int應該有提示它的長度和大小....暈

ted99tw iT邦高手 1 級 ‧ 2013-10-15 19:13:48 檢舉
<pre class="c" name="code">
void(*)(void*)

意思是一個“無傳回值的函數指標,參數為型態未知的指標”。

﹣無傳回值的函數指標:void(*)()
﹣參數為型態未知的指標:void*

這是傳統C的寫法,一般用在call back,如有用到,直接給一個函數即可,如沒用則給Null。
謝謝

總裁 iT邦好手 1 級 ‧ 2013-10-15 20:13:23 檢舉

The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and sqlite3_bind_text16() is a destructor used to dispose of the BLOB or string after SQLite has finished with it. The destructor is called to dispose of the BLOB or string even if the call to sqlite3_bind_blob(), sqlite3_bind_text(), or sqlite3_bind_text16() fails. If the fifth argument is the special value SQLITE_STATIC, then SQLite assumes that the information is in static, unmanaged space and does not need to be freed. If the fifth argument has the value SQLITE_TRANSIENT, then SQLite makes its own private copy of the data immediately, before the sqlite3_bind_*() routine returns.

總裁 iT邦好手 1 級 ‧ 2013-10-15 20:13:43 檢舉

Constants Defining Special Destructor Behavior

typedef void (*sqlite3_destructor_type)(void*);
#define SQLITE_STATIC ((sqlite3_destructor_type)0)
#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)

These are special values for the destructor that is passed in as the final argument to routines like sqlite3_result_blob(). If the destructor argument is SQLITE_STATIC, it means that the content pointer is constant and will never change. It does not need to be destroyed. The SQLITE_TRANSIENT value means that the content will likely change in the near future and that SQLite should make its own private copy of the content before returning.

總裁 iT邦好手 1 級 ‧ 2013-10-15 20:14:59 檢舉

暈果然,這種東西只有海棉才看得懂,我們人類是看不懂這東東的...Orz

ted99tw iT邦高手 1 級 ‧ 2013-10-15 20:41:32 檢舉

原來這個回調作用是GC,所以第5個參數格式應會像這樣:

<pre class="c" name="code">
sqlite3_result_blob(SQLITE_STATIC);

謝謝

我之前看不懂
經過了這30堂課的洗禮
坦白說
未來我仍然看不懂

還是用 GCP 的 design pattern
繼續誤人子弟
瞎

0
一級屠豬士
iT邦大師 1 級 ‧ 2013-10-15 13:37:09

慶賀泰大pointer 30天完成.
Jump (For My Love) - Pointer Sisters
Yes

ted99tw iT邦高手 1 級 ‧ 2013-10-15 20:17:57 檢舉

哇,她們叫我寶貝耶...開心

0
smartleos
iT邦新手 3 級 ‧ 2013-10-15 15:43:59

恭喜達陣~~~
拍手

0
roylee
iT邦高手 1 級 ‧ 2013-10-15 15:48:34

恭喜泰大~~ 完成鐵人四項的壯舉 XD

0
freelab
iT邦新手 1 級 ‧ 2013-10-15 20:23:03

四鐵拍照拍照拍照拍照

0

我要留言

立即登入留言