2015-04-23 2 views
0

Я работаю над проектом VC++ (ничего не визуально, просто используя Visual Studio для редактирования). И в одном из моих классов у меня есть куча ошибок C2061, но evreything отлично, я дважды и тройной проверял. это класс, где возникают ошибки: Circle.h:Ошибка C2061: «идентификатор», но я включил заголовок?

#ifndef __SGE__Circle__ 
#define __SGE__Circle__ 
#include <GLFW/glfw3.h> 
#include "Vector2.h" 
#include "Rectangle.h" 
class Circle 
{ 
public: 
    Circle(); 
    Circle(float xCenter, float yCenter, float radius); 
    Circle(Vector2& center, float radius); 
    ~Circle(); 
    bool Contains(Vector2& point); 
    bool Contains(Rectangle& rectangle); //ERROR OCCURS HERE 
    bool Contains(Circle& circle); 
    bool isContained(Rectangle& rectangle); //ERROR OCCURS HERE 
    bool Intersects(Rectangle& rectangle); //ERROR OCCURS HERE 
    bool Intersects(Circle& circle); 
    float Radius; 
    Vector2 Center; 
}; 
#endif 

ошибка, как это: C2061 ошибка: синтаксическая ошибка: идентификатор «Прямоугольник» и они везде появляться прямоугольник называется

Прямоугольник класс выглядит следующим образом:

Rectangle.h:

#ifndef __SGE__Rectangle__ 
#define __SGE__Rectangle__ 
#include <GLFW/glfw3.h> 
#include "Vector2.h" 
class Rectangle 
{ 
public: 
    Rectangle(); 
    Rectangle(float x, float y, float width, float height); 
    Rectangle(Vector2& position, Vector2& size); 
    ~Rectangle(); 
    Vector2* getCorners(); 
    Vector2 getCenter(); 
    bool Contains(Vector2& point); 
    bool Contains(Rectangle& rectangle); 
    bool Intersects(Rectangle& rectangle); 
    float X; 
    float Y; 
    float Width; 
    float Height; 
}; 
#endif 

и я также ИМПО к.т. как Circle.h и Rectangle.h в моей main.cpp

и для удовольствия :) Vector2.h:

#ifndef _SGE_Vector2_ 
#define _SGE_Vector2_ 
#include <GLFW/glfw3.h> 
#include <math.h> 
class Vector2 
{ 
public: 
    Vector2(); 
    Vector2(float x, float y); 
    bool operator == (const Vector2& a); 
    bool operator != (const Vector2& a); 
    Vector2 operator +(const Vector2& a); 
    Vector2 operator +=(const Vector2& a); 
    Vector2 operator -(const Vector2& a); 
    Vector2 operator -=(const Vector2& a); 
    Vector2 operator *(const float a); 
    Vector2 operator *=(const float a); 
    Vector2 operator /(const float a); 
    Vector2 operator /=(const float a); 
    float Length(); 
    void Normalize(); 
    ~Vector2(); 
    GLfloat X; 
    GLfloat Y; 
}; 
#endif 
+4

Стена с кодом! Не могли бы вы извлечь из него [минимальный пример воспроизведения] (http://stackoverflow.com/help/mcve)? – Angew

+4

Какая строка кода указывает на эту ошибку? Вы отправили много кода, из-за чего нам сложно найти решение. –

+5

[OT]: имена с двойным подчеркиванием (как '__SGE__Circle__') зарезервированы. – Jarod42

ответ

1

"GLFW/glfw3.h" содержит функции: Ьоо Прямоугольник (...); который создает ошибки при использовании класса Rectangle. Есть два решения этой проблемы:

  1. Rename класс Rectangle к чему-то другому экс: Rect
  2. Создание пространства имен, который содержит все классы решений Возможное вызвать

using namespace X; //X is replaced by the name of your namespace

в главном переопределении функции Rectangle с классом Rectangle.

Проблема была решена с помощью Саранга!

Смежные вопросы