C ++类模板无法将函数定义与现有声明匹配

时间:2014-10-18 21:13:32

标签: c++ header-files template-classes

我在头文件中有以下内容。具有许多功能的模板类。

#pragma once
#include <string>
using namespace std;    

template <class T>
class Vector3Generic
{
public:
    T x;
    T y;
    T z;

    Vector3Generic();
    ~Vector3Generic();
    Vector3Generic(T vx, T vy, T vz);
    Vector3Generic(Vector3Generic& v);
    // 
    // ... many functions, some static, and some are not.
    static T Vector3Generic::Distance(const Vector3Generic& a, const Vector3Generic& b);
    static T Vector3Generic::Slope(const Vector3Generic& linepoint1, const Vector3Generic& linepoint2);

};      
template <class T>
T Vector3Generic<T>::Distance(const Vector3Generic<T>& a, const Vector3Generic<T>& b)
{
    auto vector = Vector3Generic<T>(a.x - b.x, a.y - b.y, a.z - b.z);
    return sqrt(((vector.x * vector.x) + (vector.y * vector.y)) + (vector.z * vector.z));
}
template <class T>
T Vector3Generic<T>::Slope(const Vector3Generic<T>& linepoint1, const Vector3Generic<T>& linepoint2)
{
    return (linepoint2.z - linepoint1.z) / (linepoint2.x - linepoint1.x);
}

我的问题是我只收到上面包含的函数的错误消息。我无法弄清楚问题。

你能看出出了什么问题吗?

0 个答案:

没有答案