2013-11-01 94 views
0

我無法將值初始化爲指向對象數組的指針時出現問題。我要初始化的結構如下:無法初始化指向對象數組的指針的值

14 struct Checker 
15 { 
16 Checker(); 
17 int m_money_in_register; 
18 int m_start_work; 
19 int m_time_checkout; 
20 Cust *m_cust; 
21 }; 

這是怎麼我嘗試初始化,我只是一個開始,以確保即時通訊做正確的事:

119 Checker *checkers = new Checker[num_checkers]; 
120 for(int i =0; i < num_checkers; i++) 
121 { 
122 checkers->Checkers[i]->m_money_in_register = 500; 
123 cout << checkers->Checkers[i]->m_money_in_register << endl; 
124 } 

什麼是正確的方法要做到這一點?

回答

0

沒關係,我理解了它,它正確地做如下:

119 Checker *checkers = new Checker[num_checkers]; 
120 for(int i =0; i < num_checkers; i++) 
121 { 
122 checkers[i].m_money_in_register = 500; 
123 cout << checkers[i].m_money_in_register << endl; 
124 }