Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/134.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;模板:无法将函数定义与现有声明匹配_C++_Visual Studio 2013 - Fatal编程技术网

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

C++ C++;模板:无法将函数定义与现有声明匹配,c++,visual-studio-2013,C++,Visual Studio 2013,我目前正在为我的游戏引擎设计一个模板化的Vector2类 为了保持一切整洁,我一直在分离函数声明和定义。这在构造函数中运行良好,但是,在尝试使用静态函数进行相同操作时,我遇到以下错误: error C2244: 'spl::Vector2<T>::Dot' : unable to match function definition to an existing declaration 1> definition 1> 'T spl::

我目前正在为我的游戏引擎设计一个模板化的Vector2类

为了保持一切整洁,我一直在分离函数声明和定义。这在构造函数中运行良好,但是,在尝试使用静态函数进行相同操作时,我遇到以下错误:

error C2244: 'spl::Vector2<T>::Dot' : unable to match function definition to an existing  declaration
1>          definition
1>          'T spl::Vector2<T>::Dot(const spl::Vector2<L> &,const spl::Vector2<R> &)'
1>          existing declarations
1>          'T spl::Vector2<T>::Dot(const spl::Vector2<L> &,const spl::Vector2<R> &)'
错误C2244:'spl::Vector2::Dot':无法将函数定义与现有声明匹配
1> 定义
1> 'T spl::Vector2::Dot(const spl::Vector2&,const spl::Vector2&)'
1> 现有声明
1> 'T spl::Vector2::Dot(const spl::Vector2&,const spl::Vector2&)'
我发现不寻常的是,尽管声明和定义是相同的,编译器却无法匹配它们

这是我的Vector2课程:

// The Vector2 Class
template <typename T> 
class Vector2{
public:

    // Constructor
    Vector2 ();
    Vector2 (T Value);
    Vector2 (T XAxis, T YAxis);

    // Static Functions
    template <typename L, typename R>
    static T Dot (const Vector2 <L>& LHS, const Vector2 <R>& RHS);

    // Variables
    T x, y;
};
//Vector2类
模板
类向量2{
公众:
//建造师
向量2();
向量2(T值);
向量2(T XAxis,T YAxis);
//静态函数
模板
静态T点(常数矢量2和LHS、常数矢量2和RHS);
//变数
tx,y;
};
下面是它下面的函数声明:

// Return The Dot Product Of Two Vectors
template <typename T, typename L, typename R>
T Vector2 <T>::Dot (const Vector2 <L>& LHS, const Vector2 <R>& RHS){

    T xAxis = (T) LHS.x * (T) RHS.x;
    T yAxis = (T) LHS.y * (T) RHS.y;

    return (xAxis + yAxis);
}
//返回两个向量的点积
模板
T矢量2::点(常数矢量2和LHS,常数矢量2和RHS){
T xAxis=(T)LHS.x*(T)RHS.x;
T yAxis=(T)LHS.y*(T)RHS.y;
返回(xAxis+yAxis);
}
如果有人知道为什么会抛出这个错误以及如何修复它,我将永远欠你的债


另外,我正在Windows 8.1计算机上使用Visual Studio 2013 Ultimate。

语法需要:

template <typename T>
template <typename L, typename R>
T Vector2 <T>::Dot (const Vector2 <L>& LHS, const Vector2 <R>& RHS){

    T xAxis = (T) LHS.x * (T) RHS.x;
    T yAxis = (T) LHS.y * (T) RHS.y;

    return (xAxis + yAxis);
}
模板
模板
T矢量2::点(常数矢量2和LHS,常数矢量2和RHS){
T xAxis=(T)LHS.x*(T)RHS.x;
T yAxis=(T)LHS.y*(T)RHS.y;
返回(xAxis+yAxis);
}