首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误C2819:键入‘机器人::动画’没有重载成员‘操作符’->‘

错误C2819:键入‘机器人::动画’没有重载成员‘操作符’->‘
EN

Stack Overflow用户
提问于 2010-11-22 06:11:21
回答 1查看 894关注 0票数 0

我根本找不到这是为什么扔错了!好的,我有一个结构,里面有一些物体。然后创建指向该结构的指针,并逐一设置项。我一直在犯错误。下面是代码:

Robot.h:

代码语言:javascript
复制
// 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
};

Robot.cpp:

代码语言:javascript
复制
    // 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中。我呼吁:

代码语言:javascript
复制
Animation* mAnimation = new Animation();

在一段时间的循环中,这是好的OO设计吗?如果没有,有什么更好的方法呢?谢谢。

编辑:所以,多亏了Frédéric,原来我漏掉了一封信。但现在我听到一个错误:

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-11-22 06:16:28

我认为你的错误在于:

代码语言:javascript
复制
// Set the animations name
mAnimation->name = Animation->mAnimState->getAnimationName();

这可能应该是:

代码语言:javascript
复制
// Set the animations name
mAnimation->name = mAnimation->mAnimState->getAnimationName();
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4242773

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档