incomplete type error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • byteit101
    New Member
    • Mar 2009
    • 25

    #1

    incomplete type error

    I have a big library i am making, and I have a Event<class t, class o> class, and a Controller class
    In the Controller.h I have this

    class Controller
    { //<this is line 22 in my file
    ...
    public:
    Event<float,Con troller> XChanged; //Line 38
    Event<float,Con troller> YChanged;
    Event<float,Con troller> ThrottleChanged ;
    Event<bool,Cont roller> TriggerChanged;//line 41
    ...

    and I get the following errors
    /../../Threads/DelegateEvent.h : In instantiation of `Event<float, Controller>':
    /../tjoystick.h:38: instantiated from here
    /../../Threads/DelegateEvent.h :118: error: `Event<T, O>::objectToMon itor' has incomplete type
    /../tjoystick.h:22: error: forward declaration of `class Controller'
    /../../Threads/DelegateEvent.h : In instantiation of `Event<bool, Controller>':
    /../tjoystick.h:41: instantiated from here
    /../../Threads/DelegateEvent.h :118: error: `Event<T, O>::objectToMon itor' has incomplete type
    /../tjoystick.h:22: error: forward declaration of `class Controller'



    controller.h contains this
    template <typename T, class O> class Event
    {
    T (O::*fiiftrue)( );
    O objectToMonitor ; //<line 118
    Thread listenThread;
  • Savage
    Recognized Expert Top Contributor
    • Feb 2007
    • 1759

    #2
    Try adding forward reference,befor e the the Controller class declaration.
    Like:
    Code:
    class Controler;//forward reference
      //.....
      class Controler
      {
         //   
      };
    If it happens to not work you can make objectToMonitor to be a pointer, that way it should work for sure.

    Comment

    Working...