CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2009
    Posts
    20

    Help need with c++ forward declarations

    I am new to using forward declarations. I thought I had understood quite a bit of it until I got this error. Seems there is something really really basic that I miss. can some one of you help me with this error???

    src/BaseBodyDynamics.cpp:15: error: invalid use of incomplete type 'struct Xlib::Quatf'
    include/BaseBodyDynamics.h:19: error: forward declaration of 'struct Xlib::Quatf'


    basically i tried forward declaring the class Quat . Then had a variable declared in the header file which was a pointer. When i try using the variable in the cpp file after including Quaternion.h which is the parent file of Quat I get this error.

    A small code snippet
    Code:
    //Header file
    class *Quat;
    Quatf* m_qSObjectSpin;
    
    //cpp file
    m_qSObjectSpin->normalize();
    Actually the quaternion is a part of the struct i have defined in my class..I am not sur eif that is causing the error or if there is any better way to do this.

    Cheers

  2. #2
    Join Date
    Jun 2007
    Location
    MA-USA
    Posts
    247

    Re: Help need with c++ forward declarations

    header file...
    Code:
    class CObject;
    
    class CObjectManager {
    public:
       CObject *m_ptrObjects;
       int m_numObjects;
    };
    source file...
    Code:
    #include "ObjectManager.h"
    #include "Object.h"
       ...

  3. #3
    Join Date
    Mar 2009
    Posts
    20

    Re: Help need with c++ forward declarations

    It seems I have given exactly the same format in the header file and the cpp file as told above.. But still i get the same error

    src/BaseBodyDynamics.cpp:15: error: invalid use of incomplete type 'struct Xlib::Quatf'
    include/BaseBodyDynamics.h:19: error: forward declaration of 'struct Xlib::Quatf'

    Can someone help me with this

Tags for this Thread

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured