我无法找到为什么这会引发错误!好的,所以我有一个包含一些对象的结构。然后我创建一个指向该结构的指针并一一设置项目。通过我不断收到错误。这是代码:
机器人.h:
// Name and Animation info
std::map<std::string, Ogre::AnimationState*> mAnims2;
struct Animation {
std::string name; // The name of the animation state
Ogre::AnimationState* mAnimState; // The actual animation state
bool FADE_IN; // Fade the animation in
bool FADE_OUT; // Fade the animation out
};
机器人.cpp:
// Go through the set by using iterator
while (animStateIter.hasMoreElements()) {
// The Animation object we will construct
Animation* mAnimation = new Animation();
// Initial values for Fading In and Out
mAnimation->FADE_IN = false;
mAnimation->FADE_OUT = false;
// Create the Animation object, using the next animation in the list
mAnimation->mAnimState = animStateIter.getNext();
// Set the animations name
mAnimation->name = Animation->mAnimState->getAnimationName();
// Make sure the animation is set to Loop
mAnimation->mAnimState->setLoop( true );
// Insert the Animation object into the list of Animations
mAnims2.insert( std::make_pair( mAnimation->name, mAnimation) );
/* DEBUG */
output << mAnimation->name << std::endl;
}
错误:
Error 1 error C2819: type 'Robot::Animation' does not have an overloaded member 'operator ->' c:\users\masry\school-work\fall-2010\cs-425\homework-4\gameengine_solution\robot.cpp 52
另外,如果您注意到,我正在尝试动态创建 Struct 对象并将它们插入到 Map 中。我打电话:
Animation* mAnimation = new Animation();
在 while 循环中,这是好的 OO 设计吗?如果没有,有什么更好的方法?谢谢你。
编辑: 所以,多亏了 Frédéric,我发现我错过了一封信。但现在我收到一条错误消息:
Error 17 error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::string' c:\users\masry\school-work\fall-2010\cs-425\homework-4\gameengine_solution\robot.cpp 58