令人困惑的缺少类型说明符错误

时间:2014-04-22 01:21:12

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

我对C4430 missing type specifier error的所有用途感到困惑Vector4D。我不明白为什么会被扔掉。它被宣布了。它被定义了。它存在。它结构良好。 (我注释掉了所有的用法,包括除了类定义/声明以外的代码,编译的代码。)并且它包括在内。

代码as-is适用于VS2012,但不适用于VS2010。

以下是Vector2D类中的用法示例。 Vector3D包括Vector4D GetHomogeneous() const;等。人

#ifndef A2DE_CVECTOR2D_H
#define A2DE_CVECTOR2D_H

#include "../a2de_vals.h"
#include "CMiscMath.h"

#include "CVector3D.h"
#include "CVector4D.h"

A2DE_BEGIN

class Vector2D {

public:

    Vector2D();
    Vector2D(double x, double y);
    Vector2D(const Vector2D& vector);
    Vector2D(const Vector3D& v3d);
    Vector2D(const Vector4D& v4d);
    Vector2D(const Math::PolarCoordinate& magnitude_and_angle);
    ~Vector2D();
    double GetX() const;
    double GetX();
    double GetY() const;
    double GetY();
    double GetLength() const;
    double GetLength();
    double GetLengthSquared() const;
    double GetLengthSquared();
    double DotProduct(const Vector2D& rhs) const;
    static double DotProduct(const Vector2D& a, const Vector2D& b);
    Vector2D Normalize() const;
    static void Normalize(Vector2D& v);
    Vector2D GetLeftNormal() const;
    Vector2D GetLeftNormal();
    Vector2D GetRightNormal() const;
    Vector2D GetRightNormal();
    Vector2D GetProjection(const Vector2D& b);
    static Vector2D GetProjection(const Vector2D& a, const Vector2D& b);
    Vector2D GetProjectionOnXAxis();
    Vector2D GetProjectionOnYAxis();
    double GetAngle() const;
    double GetAngle();
    static double GetAngle(const Vector2D& v);
    double GetAngleFrom(const Vector2D& b);
    static double GetAngleFrom(const Vector2D& b, const Vector2D& a);
    static double GetFacingAngle(const Vector2D& target, const Vector2D& source);
    static Vector2D GetFacingVector(const Vector2D& target, const Vector2D& source);
    Vector2D& operator=(const Vector2D& rhs);
    Vector2D& operator=(const Vector3D& rhs);
    Vector2D& operator=(const Vector4D& rhs);
    bool operator==(const Vector2D& rhs);
    bool operator==(const Vector2D& rhs) const;
    bool operator!=(const Vector2D& rhs);
    bool operator!=(const Vector2D& rhs) const;
    Vector2D& operator+=(double scalar);
    Vector2D& operator-=(double scalar);
    Vector2D& operator*=(double scalar);
    Vector2D& operator/=(double scalar);
    Vector2D operator+(const Vector2D& rhs) const;
    Vector2D operator+(const Vector2D& rhs);
    Vector2D operator-(const Vector2D& rhs) const;
    Vector2D operator-(const Vector2D& rhs);
    Vector2D operator-();
    Vector2D operator*(const Vector2D& rhs) const;
    Vector2D operator*(const Vector2D& rhs);
    Vector2D operator/(const Vector2D& rhs) const;
    Vector2D operator/(const Vector2D& rhs);
    Vector2D& operator+=(const Vector2D& rhs);
    Vector2D& operator-=(const Vector2D& rhs);
    Vector2D& operator*=(const Vector2D& rhs);
    Vector2D& operator/=(const Vector2D& rhs);
    operator Vector3D();
    operator Vector4D();
    Vector3D GetHomogeneous() const;
    Vector3D GetHomogeneous();
    friend Vector2D operator+(const Vector2D& v_lhs, double scalar_rhs);
    friend Vector2D operator+(double scalar_lhs, const Vector2D& v_rhs);
    friend Vector2D operator-(const Vector2D& v_lhs, double scalar_rhs);
    friend Vector2D operator-(double scalar_lhs, const Vector2D& v_rhs);
    friend Vector2D operator*(const Vector2D& v_lhs, double scalar_rhs);
    friend Vector2D operator*(double scalar_lhs, const Vector2D& v_rhs);
    friend Vector2D operator/(const Vector2D& v_lhs, double scalar_rhs);
    friend Vector2D operator/(double scalar_lhs, const Vector2D& v_rhs);

protected:

    void SetX(double x);
    void SetY(double y);
    void SetTerminal(double x, double y);

    double _x;
    double _y;
    double _angle;

private:
};


A2DE_END

#endif

1 个答案:

答案 0 :(得分:1)

在头文件中包含类似的类型会让我觉得你可能有循环依赖。建议在标头中使用前向声明,并且从Vector2D定义中可以看出,您可以使用以下内容代替#includes

class Vector3D;
class Vector4D;