作者rilak1314 (與未來共舞)
看板C_and_CPP
標題[問題] 指標用法 vector<自定義結構>
時間Fri Jan 16 13:02:44 2015
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC2010
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
我想將vector<LBP_Encoder> 型態用指標方式傳入函數,
目的是 [為了傳入函數並修改結構內資料],
但指標與向量&結構概念結合不太清楚,
想知道如何宣告比較能達成
餵入的資料(Input):
vector<LBP_Encoder> encoder
預期的正確結果(Expected Output):
encoder.roi 內容成功修改
錯誤結果(Wrong Output):
無法執行 Error:no operator "<<" matches these operands
程式碼(Code):(請善用置底文網頁, 記得排版)
struct LBP_Encoder{
DAB_Model model;
Rect roi;
int splitx;
int splity;
};
typedef struct LBP_Encoder LBP_Encoder;
vector<LBP_Encoder> encoder;
vector<LBP_Encoder> *ptr;
ptr=&encoder;
cout<< *ptr.roi.x <<endl;
LDP_based_on_Landmark(ptr);
補充說明(Supplement):
我是弱弱的機械初學者QQ...
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.118.199.217
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1421384569.A.8A5.html
※ 編輯: rilak1314 (140.118.199.217), 01/16/2015 13:03:40
推 Zero0910: 宣告 LDP_based_on_Landmark(vector<LBP_Encoder>&vec); 01/16 13:59
→ Zero0910: call的時候直接LDP_based_on_Landmark(encoder); 就好 01/16 13:59
→ rilak1314: 謝謝大大!! 01/16 14:51
→ ACMANIAC: cout<< (*ptr).roi.x <<endl; 01/17 01:58
→ ACMANIAC: cout<< ptr->roi.x <<endl; 01/17 01:58