Frward declaration templating

Hi guys

I had a post going sometime before this error .. But could nt follow up on it.. Pardon me for that.. I am trying to do a bit of forward declarations in my program and wrote a couple of classes but then I run into this error which I do not seem to solve


src/BaseBodyDynamics.cpp: In member function 'void Xlib::BaseDynamics::State::RecalculateState()':
src/BaseBodyDynamics.cpp:15: error: invalid use of incomplete type 'struct Xlib::Quatf'
include/BaseBodyDynamics.h:21: error: forward declaration of 'struct Xlib::Quatf'

Pardon me if it is somethin trivial but then it would be nice for someone to chip in with a answer to why this is happening
..


I jus compiled all the code that I thought could be causing the error..


1
2
3
4
5
6
7
8
9
10
11
12
13
14
//test.h
class Quatf;

class Test{
 //ctor
 Test();
//dtor
~Test() ;
public:
struct state{
  Quatf* myvariable;
  void recalculate();
}
}

1
2
3
4
5
6
//test.cpp
#include "test.h"

void Test::state::recalculate(){
   myvariable-> 
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//Quaternion.h 
template < class T>
class Quat
{
  T x;
   T y;
   T z;
   T w;
  
   Quat(T _x, T _y,T _z, T _r) : x (_x),y(_y),z(_z),w(_w){}
    
   Quat<T>& normalize();
   
   T length();

};

inline Quat<T>& Quat<T>::normalize()
{
   if ( T l = length() ) { r /= l; v /= l; }
   return *this;
}

inline T Quat<T>::length()
{
   return sqrt(x*x+y*y+z*z+w*w);
}


typedef Quat<float> Quatf;


I hope some one can help
You need to include Quaternion.h in test.h or test.cpp
oops.. sorry to have not put it ere.. i have included it in the actual file.. i jus wrote a quick snippet of my code because i did nt want to spam the forum with all my codes.. will edit the above
Topic archived. No new replies allowed.