有谁知道这段代码有什么问题?
Does anyone know what is the problem in this code?
我正在用C++和OpenGL编写一个应用程序。在这个头文件中,我只想从我的 ObstacleS 类中的 ObstacleSConnection 类创建一个对象,但我得到这三个错误。
-
语法错误:前面缺少";"
-
";"前面的意外标记
-
缺少类型说明符 - 假定为 int。注意:C++不支持 默认整型
由于我是 c++ 的新手,我知道我的错误很简单,你能帮帮我吗?
障碍S.h
#pragma once
#pragma warning
class ObstacleS
{
public:
ObstacleS(cyclone::Vector3& p);
~ObstacleS();
ObstacleSConnection * sconnection; (error is here)
cyclone::Vector3 m_color;
cyclone::Particle* m_particle;
cyclone::ParticleForceRegistry* m_forces;
void update(float duration);
void draw(int shadow);
};
class ObstacleSConnection
{
public:
ImplicitEngine* _engine;
int MAX_CONTACTS = 5000;
int numStatics;
ObstacleSConnection(int n);
~ObstacleSConnection();
std::vector<cyclone::ParticleContactGenerator*> m_grounds;
cyclone::ParticleContactResolver* m_resolver;
std::vector<ObstacleS*> m_statics;
size_t addObstacle(const std::vector<cyclone::Vector3>& vertices);
std::vector<Obstacle*> obstacles_;
};
C++不知道ObstacleSConnection
何时使用它在类中定义指针ObstacleS
而不是定义ObstacleSConnection
。这是因为定义这两个类的顺序。因此,您需要在代码中向前声明ObstacleSConnection
。只需在上课前使用下面的行ObstacleS
即可。
class ObstacleSConnection;
您可以在此处阅读有关前向声明的更多信息。
相关文章:
- 警告处理为错误这里有什么问题
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 当我尝试添加 2 个大字符串时,我无法弄清楚出了什么问题
- 违反const正确性:我应该现实地期待什么问题
- 这个带有模板<类 Vector 的C++代码片段有什么问题>
- 我的逻辑反转字符串中的元音有什么问题?
- 需要以下代码的帮助,下面的代码有什么问题
- 常量公共成员有什么问题?
- 以下代码中的函数模板有什么问题?
- 这个返回元素位置的基于循环的函数有什么问题?
- creat_list2功能有什么问题?
- 格式说明符C++有什么问题
- 任何人都可以告诉我我的 C++ 代码出了什么问题?
- 从 argv[1] 转换为字符 * 字符串后有什么问题?
- 我的堆栈和库存清单程序的结构有什么问题?
- 此工厂功能有什么问题?
- 以下 C++ 代码有什么问题?
- 数组为此合并排序函数提供了正确的输出,但向量给出了不正确的输出.出了什么问题?
- reinterpret_cast,只读访问,简单的可复制类型,会出什么问题?
- 它解决了什么问题,对于非真空初始化,生命周期在初始化之前就开始了