微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

错误:“公共”之前的预期标识符

如何解决错误:“公共”之前的预期标识符

我目前正在尝试为 GBA Game Jam 制作一个 GBA 游戏,无论如何我在尝试编译时基本上消除了所有错误我认为这些最后的错误是相互关联的,所以无论如何这里是错误我认为这一切都与:

error: expected identifier before 'public'
   38 | class gbaEngine :: public engine

以下是其余错误

error: expected unqualified-id before 'public'
error: cannot call member function 'virtual bool gbaEngine::OnUserCreate()' without object
  190 |     gbaEngine::OnUserCreate();
cannot call member function 'void gbaEngine::Start()' without object
  189 |     gbaEngine::Start();
error: cannot call member function 'virtual bool gbaEngine::OnUserCreate()' without object
  190 |     gbaEngine::OnUserCreate();

无论如何,这里是您可能需要查看的脚本部分(尽管如果您认为它可能在其他地方,请随时询问):

engine.cpp:

#include "GBA3D/engine.h"
#include <stdio.h>
#include <math.h>
#include <vector>
#include <iostream>
#include <thread>
#include <fstream>
#include <strstream>
#include <algorithm>
#include <string>
#include "toolBox.h"

struct vec3d
{
    float x,y,z;
};

struct triangle
{
    vec3d p[3];
};

struct mesh
{
    std::vector<triangle> tris;
};

struct mat4x4
{
    float m[4][4] = { 0 };
};

class gbaEngine :: public engine
{
public:
    //Stuff in here
};

engine.h:

#ifndef ENGINE_H
#define ENGINE_H

#include <stdio.h>
#include <math.h>
#include <fstream>
#include <iostream>
#include <strstream>
#include <algorithm>
#include <vector>
#include <string>
#include <thread>
#include "toolBox.h"

//#define REG_TM2D -0x4000                        //0x4000 ticks till overflow
//#define REG_TM2CNT TM_FREQ_1024                 //we're using the 1024 cycle timer
//#define REG_TM3CNT TM_ENABLE | TM_CASCADE

//typedef uint32_t u32;
//typedef int32_t  s32;

bool m_bAtomActive;


class gbaEngine
{
public:
    //Stuff in here
};

#endif

如果你能帮忙,请做

提前致谢

解决方法

应该是这样的:

class B : class A

这将使 B 类继承 A 类。

你有:

class gbaEngine :: public engine

代替:

class gbaEngine : public engine

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。