錯誤代碼
for (iterAcceItem j = objAccelerator.p_accle_items().begin(); ...)
原因
p_accle_items 是 **公有成員變量** (`vector p_accle_items;`),**不是函數**,調用時**不需要括號**。編譯器嘗試將 `p_accle_items` 作為函數調用,導致 C2064: term does not evaluate to a function taking 0 arguments。
修正
for (iterAcceItem j = objAccelerator.p_accle_items.begin(); j != objAccelerator.p_accle_items.end(); ++j) {
CAcceleratorItem* pobjAcceleratorItem = *j;
// ...
}
補充建議
- 成員變量命名建議加前綴 `m_` 或 `_`,如 `m_accleItems`,避免與函數混淆。
- 使用範圍 for (C++11) 更簡潔:`for (auto* item : objAccelerator.p_accle_items) { ... }`。
- 檢查 `AUTO_PROPERTY` 宏展開是否產生同名函數導致遮蓋。