Results 1 to 4 of 4

Thread: Vector-class with template

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts

    Vector-class with template

    Okay, this is actually C++ but i didnt want to open a new thread for it

    basically i wrote a simple 3d vector class and i wanted to template it in the way you can pass in any 3d vector in its constructor:

    PHP Code:
    templatetypename T >
    class 
    Vec3
    {
        public:

            
    T x z;

            
    template< class Tvec >
            
    Vec3( const Tvec);
    };

    templatetypename T >
    template< class Tvec >
    Vec3>::Vec3( const Tvec)
    {
        
    Tv.);
        
    Tv.);
        
    Tv.);
    }

    //Needed useage (Bullet's btVector3 as example):

    btVector3 v1 btVector31.0 2.0 3.0 );
    Vec3 v2 Vec3v1 ); 
    The error:
    Code:
    error C2228: left of '.x' must have class/struct/union
    error C2228: left of '.y' must have class/struct/union
    error C2228: left of '.z' must have class/struct/union
    Last edited by kung foo man; 29th November 2013 at 21:28. Reason: made new thread for different problem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •