gpt4 book ai didi

尽管包含 header ,但 C++ 成员访问不完整类型

转载 作者:行者123 更新时间:2023-11-28 02:49:08 25 4
gpt4 key购买 nike

我在使用前向声明时遇到了一个奇怪的问题。这是代码:

Torse 类,torse.hpp

#ifndef _TORSE_
#define _TORSE_

class Animation;
enum frame_type;

class Torse : public Renderable
{
public:
const glm::vec3& getCurrentRotation(frame_type);
};
#endif

在 torse.cpp 中:

#include "torse.hpp"
#include "animation.hpp"
const glm::vec3& Torse::getCurrentRotation(frame_type t)
{...}

现在在动画类中,animation.hpp

#ifndef __ANIMATION_H__
#define __ANIMATION_H__

class torse;

class frame {...};
class Animation {

public:
void generateInterpolation(torse& me);
};
#endif

在 animation.cpp 中:

#include "animation.hpp"
#include "torse.hpp"
void Animation::generateInterpolation(torse &me)
{
...
f1.rot[j] = me.getCurrentRotation(f1.type)[j];
...
}

如您所见,我正在共享枚举 frame_type 和类 Anmation 和 Torse 但我觉得我做对了,因为在 animation.cpp 中它应该知道 torse 是多亏了 torse.hpp...

clang 给我这个错误:

src/animation.cpp:19:43: error: member access into incomplete type 'torse'
f1.rot[j] = me.getCurrentRotation(f1.type)[j];
^

有人知道吗?

最佳答案

您定义了一个类型 Torse,但 clang 提示名为 torse 的类型。

解决您的问题。

关于尽管包含 header ,但 C++ 成员访问不完整类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23458415/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com