看到一段程序:CTreeCtrl* pCtrl = &GetTreeCtrl();1、這個&是干什么用的?2、這個函數是干什么用的?為什么拿這個函數來初始化pCtrl ?
3 回答

慕田峪4524236
TA貢獻1875條經驗 獲得超5個贊
這里的&就是普通取地址用的,將一個地址賦值給pCtrl。
另外:
函數GetTreeCtrl() 本事是一個返回引用的函數(不明白這說法的可以去翻基礎書),所以也可以這么寫:
CTreeCtrl& theCtrl = GetTreeCtrl();
theCtrl.xxxxx ....;
這里的 '&' 是引用的意思

四季花海
TA貢獻1811條經驗 獲得超5個贊
CTreeView::GetTreeCtrl
CTreeCtrl& GetTreeCtrl( ) const;
Returns a reference to the tree control associated with the view.
- 3 回答
- 0 關注
- 274 瀏覽
添加回答
舉報
0/150
提交
取消