C++ - 无法通过构造函数初始化类变量

khm*_*040 0 c++

我是C++的新手,我在通过构造函数设置类变量时遇到问题.
我将所有的.h和.cpp文件设置为我认为正确的方式.
但是我一直在第4行和第5行遇到错误.我使用的是Visual Studio 2013.错误说Vector3:'class'类型重定义.x,y,z不是Vector3类的非静态数据成员或基类.谢谢你的建议.

Vector3.h:

#ifndef VECTOR3_H
#define VECTOR3_H

#include <iostream>
#include <array>

class Vector3
{
    public:
        float x;
        float y;
        float z;

        Vector3(float _x, float _y, float _z);
        Vector3(const Vector3 &v);
        Vector3(Vector3 start, Vector3 end);

        Vector3 add(Vector3 v);
        Vector3 sub(Vector3 v);
        Vector3 scale(float scalar);

        float length();
        void normalize();
        float dot(Vector3 v3);
        float angleTo(Vector3 n);
        Vector3 cross(Vector3 v2); 

        static bool isInFront(Vector3 front, Vector3 location, Vector3 target);

        static Vector3 findNormal(Vector3 points[]);
};

#endif
Run Code Online (Sandbox Code Playgroud)

Vector3.cpp:

#include "Vector3.h"

class Vector3
{ // error on this line
    Vector3(float _x, float _y, float _z) : x(_x), y(_y), z(_z) // error initializing variables
    {

    }

    Vector3(const Vector3 &v)
    {

    }

    Vector3(Vector3 start, Vector3 end)
    {

    }


    Vector3 add(Vector3 v)
    {

    }

    Vector3 sub(Vector3 v)
    {

    }

    Vector3 scale(float scalar)
    {

    }

    float length()
    {

    }

    void normalize()
    {

    }

    float dot(Vector3 v3)
    {

    }

    float angleTo(Vector3 n)
    {

    }

    Vector3 cross(Vector3 v2)
    {

    }

    static bool isInFront(Vector3 front, Vector3 location, Vector3 target)
    {

    }

    static Vector3 findNormal(Vector3 points[])
    {

    }
};
Run Code Online (Sandbox Code Playgroud)

Nia*_*all 7

你正在重新定义class Vector3.

它应该是(实施);

Vector3::Vector3(float _x, float _y, float _z) : x(_x), y(_y), z(_z)
// ^^^^
{
}
Run Code Online (Sandbox Code Playgroud)

等等所有成员方法.