0

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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Craig
  • 1,199
  • 1
  • 13
  • 27
  • 2
    If the constructors are implemented outside the header, make sure you repeat template where they're implemented. – Justin Ardini Jun 19 '10 at 16:46
  • 5
    You're missing a `;` after The `Vector3(void)` constructor. – sth Jun 19 '10 at 16:52
  • Ugh thanks sth, i swear you can look at code for an hour and not see it. Give it to someone else and they spot it straight away.... if you wanna post that as the answer i will make accept it – Craig Jun 19 '10 at 17:16
  • 1
    And you've got an extra `;` after the destructor. And why have you got a pointer to an `auto_ptr`? – Mike Seymour Jun 19 '10 at 17:18
  • I have no idea why i made that a point Mike, late night coding at its best. I think i should go to bed now :P – Craig Jun 19 '10 at 17:19
  • I also recommend you removing (void). The correct is Vector3(); – Pavel Radzivilovsky Jun 19 '10 at 18:45
  • Try using an IDE to code. May be it would point such mistakes in the GUI. Since most of the times such compilation errors can be misleading. – Jagannath Jul 12 '10 at 06:09

1 Answers1

2

You're missing a ; after the Vector3(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.)

sth
  • 222,467
  • 53
  • 283
  • 367