【发布时间】:2011-12-28 22:49:16
【问题描述】:
所以这里有一个例子。星号的mLocation 和mSpeed 是Vector3 自定义类型。
我试过了:
Star &star = *iStar;
Star star = *iStar;
直接使用iStar-> 不适用于我的运营商,不知道为什么。
那么这样做的正确方法是什么?
void UniverseManager::ApplySpeedVector()
{
std::list <Star>::const_iterator iStar;
for (iStar = mStars.begin(); iStar != mStars.end(); ++iStar)
{
// how to I get a hold on the object the iterator is pointing to so I can modify its values
// i tried Star &star = *iStar; this is illegal
// tried just using the iStar->mLocation += iStar->mSpeed this also fails due to the operator not accepting the values not sure why
// tried other things as well, so what is the proper way to do this?
iStar->SetLocationData( iStar->mLocation += iStar->mSpeed);
}
}
【问题讨论】: