【问题标题】:In Visual Studio 2013 C++ I have clearly defined a class and am receiving errors saying that it is not a class在 Visual Studio 2013 C++ 中,我已经明确定义了一个类,并且收到错误说它不是一个类
【发布时间】:2016-02-24 04:09:54
【问题描述】:

这是我的类(网格)的头文件

#ifdef MESH_H
#define MESH_H
#include <glm\glm.hpp>
#include <GL\glew.h>
class Vertex
{
public:
    Vertex(const glm::vec3& pos)
    {
        this->pos = pos;
    }
protected:
private:
    glm::vec3 pos;

};

class Mesh
{
public:
    Mesh(Vertex* vertices, unsigned int numVertices);

    void Draw();

    virtual ~Mesh();

protected:
private:
    Mesh(const Mesh& other);
    void operator = (const Mesh& other);

    enum 
    {
        POSITION_VB,

        NUM_BUFFERS
    }

    GLuint g_vertexArrayObject;
    GLuint g_vertexArrayBuffers(NUM_BUFFERS);
    unsigned int g_drawCount;
};
#endif

这是我得到的主要错误。所有其他错误都基于这个错误。

Error 1 error C2653: 'Mesh' : is not a class or namespace name

请帮助我,因为这没有任何意义,因为我已将“网格”明确定义为一个类。谢谢

【问题讨论】:

  • 哪一行有错误?
  • 当我使用 Mesh::Mesh() 时我的 cpp 文件的行{}
  • 是的,我确实在 cpp 文件中包含了标题
  • 显示 cpp 文件。那是C2653编译过程中的第一个错误吗?
  • 是的,这是编译过程中的第一个错误

标签: c++ visual-studio class compiler-errors


【解决方案1】:

你的类实际上并没有被定义。 我认为#ifdef MESH_H 应该是#ifndef MESH_H

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-05
    • 1970-01-01
    • 1970-01-01
    • 2015-12-17
    • 2021-01-29
    • 2023-01-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多