简体   繁体   English

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

[英]Confusing missing type specifier error

I am getting a confusing C4430 missing type specifier error for all uses of Vector4D . 我对Vector4D所有使用都遇到一个令人困惑的C4430 missing type specifier error I don't understand why it's being thrown. 我不明白为什么要扔它。 It's declared. 宣布了。 It's defined. 已定义。 It exists. 它存在。 It is well-formed. 格式正确。 (I commented out all uses and includes other than the class definition/declaration, the code compiled.) and it is included. (我注释掉了所有用法,除了类定义/声明和编译的代码之外,还包括其他内容)。

The code as-is works in VS2012 but not VS2010. 代码按原样在VS2012中工作,但在VS2010中不工作。

Here is a sample of the uses in the Vector2D class. 这是Vector2D类中的Vector2D There are similar for Vector3D including Vector4D GetHomogeneous() const; Vector3D也有类似的东西,包括Vector4D GetHomogeneous() const; et. 等。 al. 人。

#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

Including similar types in header files is leading me to think you may have circular dependencies. 在头文件中包含类似类型使我认为您可能具有循环依赖性。 It is recommended to use forward declarations in headers, and it appears from your Vector2D definition that instead of the #includes , you can simply use: 建议在标头中使用前向声明,并且从Vector2D定义中可以Vector2D ,代替#includes ,您可以简单地使用:

class Vector3D;
class Vector4D;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM