serthy
29th November 2013, 20:58
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:
template< typename T >
class Vec3
{
public:
T x , y , z;
template< class Tvec >
Vec3( const Tvec& v );
};
template< typename T >
template< class Tvec >
Vec3< T >::Vec3( const Tvec& v )
{
x = T( v.x );
y = T( v.y );
z = T( v.z );
}
//Needed useage (Bullet's btVector3 as example):
btVector3 v1 = btVector3( 1.0 , 2.0 , 3.0 );
Vec3 v2 = Vec3( v1 );
The error:
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
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:
template< typename T >
class Vec3
{
public:
T x , y , z;
template< class Tvec >
Vec3( const Tvec& v );
};
template< typename T >
template< class Tvec >
Vec3< T >::Vec3( const Tvec& v )
{
x = T( v.x );
y = T( v.y );
z = T( v.z );
}
//Needed useage (Bullet's btVector3 as example):
btVector3 v1 = btVector3( 1.0 , 2.0 , 3.0 );
Vec3 v2 = Vec3( v1 );
The error:
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