没有构造函数的实例 --- 匹配参数列表(可能是模板问题)
我目前正在尝试为 cml 编写一个基本包装器(http://www.cmldev.net/ )我正在从事的项目的数学库。 我有一个 cml 向量类的包装器,它有一个私有成员
#ifndef VECTOR3_H_
#define VECTOR3_H_
#include "cml\cml.h"
#include <memory>
namespace Math
{
template<typename T>
class Vector3
{
public:
Vector3( void )
Vector3(T x, T y, T z);
~Vector3(){};
//@Function: Set
//@Description: Set the internals of the vector
//@Parameters: 3 values x, y, z
void set(T x, T y, T z);
private:
// ------------------------------------------------------------
// Copy constructor and assignment operator should be private
Vector3 (const Vector3 &);
Vector3& operator= (const Vector3 &);
//-------------------------------------------------------------
std::auto_ptr<cml::vector<T, cml::fixed<3, -1>> *m_internalVector ;
};
}
(请注意,我省略了构造函数的实现以减小大小)
,在另一个文件中,我使用一些 #defines 来使我的单词更容易。
//Vectors
typedef Math::Vector3<float> Vector3f;
//typedef cml::vector2f Vector2f;
typedef Math::Vector3<int> Vector3i;
//typedef cml::vector2i Vector2i;
现在,当我尝试使用 Vector3f 时出现问题
Vector3f forwards( 0.0f, 0.0f, 1.0f );
并收到错误:
“没有构造函数 'Math::Vector3::Vector3 [with T = float]' 的实例与参数列表匹配”
我尝试从 auto_ptr
更改为常规指针,以防模板出现问题也尝试在不使用 #define 的情况下声明变量,并且发生了同样的问题,我是否在这里遗漏了一些东西,因为我可以在实现中看到该构造函数。
I am currently trying to write a basic wrapper for the cml (http://www.cmldev.net/) math library for a project I am working on.
I have a wrapper for the cml vector class which has one private member
#ifndef VECTOR3_H_
#define VECTOR3_H_
#include "cml\cml.h"
#include <memory>
namespace Math
{
template<typename T>
class Vector3
{
public:
Vector3( void )
Vector3(T x, T y, T z);
~Vector3(){};
//@Function: Set
//@Description: Set the internals of the vector
//@Parameters: 3 values x, y, z
void set(T x, T y, T z);
private:
// ------------------------------------------------------------
// Copy constructor and assignment operator should be private
Vector3 (const Vector3 &);
Vector3& operator= (const Vector3 &);
//-------------------------------------------------------------
std::auto_ptr<cml::vector<T, cml::fixed<3, -1>> *m_internalVector ;
};
}
(Note I have left out implementations of the constructors to keep the size down)
and in another file I use some #defines to make my word easier.
//Vectors
typedef Math::Vector3<float> Vector3f;
//typedef cml::vector2f Vector2f;
typedef Math::Vector3<int> Vector3i;
//typedef cml::vector2i Vector2i;
Now my issue occurs when I try to use Vector3f
Vector3f forwards( 0.0f, 0.0f, 1.0f );
and I get the error:
"No instance of constructor 'Math::Vector3::Vector3 [with T = float]' Matches Argument List"
I have tried changing from auto_ptr
to a regular pointer in case it was an issue with the templating also have tried to declare the variable without using the #define
and the same issue occurs, am I missing something here because I can see that constructor in my implementation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在
Vector3(void)
构造函数之后缺少;
。<子>
(但我不得不承认,我认为这只是问题中的拼写错误,并不一定是问题的真正原因。)
You're missing a
;
after theVector3(void)
constructor.(But I have to admit that I thought that this was just a typo in the question, not necessarily the real cause of the problem.)