invalid use of undefined type, .h file confusion

Discussion in 'C++' started by vfunc@talktalk.net, Feb 11, 2006.

  1. Guest

    I have three files tbenbase.h, tbenbase.cpp and tbtst.cpp
    The class enmutable is forward declared in tbenbase.h and defined in
    tbenbase.cpp.
    This is within namespace tb in all files. The header is referenced at
    the top
    of tbtst.cpp outside of the namespace.

    the reference in tbtst.cpp is
    class eninv : public enmutable

    the class declaration starts
    class enmutable : public enbase

    and the forward declaration is
    class enmutable;

    the error is
    tbtst.cpp:9: error: invalid use of undefined type `struct
    tb::enmutable'

    struct?
    My compiler is gcc, I do not mention .h to the compiler / linker in the
    make file.
    How do I correct this?
     
    , Feb 11, 2006
    #1
    1. Advertising

  2. It seems that you should move the emutable class definition from
    thenbase.cpp to thenbase.h file. This error is due to an incomplete
    type error.
    because the expression "class eninv : public enmutable" in tbtst.cpp
    file requires the emutable to be a complete type(it means by so far it
    should be able to see the complete type definition of emutable),
    however from tbenbase.h file it could only see a forward declaration
    about enmutable.
     
    Audison.Athena, Feb 11, 2006
    #2
    1. Advertising

  3. Guest

    No, I tried this and not suprisingly it tells me that it is redefined
    in thenbase.cpp.
    I am going in circles because this is the error that prompted me to
    split thenbase.cpp
    into two files in the first place.
     
    , Feb 11, 2006
    #3
  4. Guest

    what should the forward declaration of enbase look like ?
     
    , Feb 11, 2006
    #4
  5. Guest

    OK, thanks for the help. A case of thinking through what it looks like
    to the compiler.
     
    , Feb 11, 2006
    #5
  6. you should enumutable class definition to the thenbase.h file and
    remove corresponding definition in thenbase.cpp file, then both in
    thenbase.cpp file and tbtst.cpp file include the thenbase.h file, then
    no redefinition error will occur.
     
    Audison.Athena, Feb 11, 2006
    #6
  7. Default User Guest

    wrote:

    > OK, thanks for the help. A case of thinking through what it looks
    > like to the compiler.


    What help?


    Brian
    --
    Please quote enough of the previous message for context. To do so from
    Google, click "show options" and use the Reply shown in the expanded
    header.
     
    Default User, Feb 11, 2006
    #7
  8. Default User Guest

    Audison.Athena wrote:

    > you should enumutable class definition


    Who should?



    Brian
    --
    Please quote enough of the previous message for context. To do so from
    Google, click "show options" and use the Reply shown in the expanded
    header.
     
    Default User, Feb 11, 2006
    #8
  9. Guest

    Well until you entered the thread there was only one person that helped
    me, so the ambiguity is in your head.

    Default User wrote:
    > Audison.Athena wrote:
    >
    > > you should enumutable class definition

    >
    > Who should?
    >
    >
    >
    > Brian
    > --
    > Please quote enough of the previous message for context. To do so from
    > Google, click "show options" and use the Reply shown in the expanded
    > header.
     
    , Feb 12, 2006
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    6,788
    chhenning
    Jul 15, 2005
  2. Anonymous Infidel - Aborted Islam with a hanger

    use of undefined type????

    Anonymous Infidel - Aborted Islam with a hanger, Jun 6, 2007, in forum: C++
    Replies:
    3
    Views:
    743
    Anonymous Infidel - Aborted Islam with a hanger
    Jun 6, 2007
  3. Phil Carmody

    Confusion about undefined behaviour

    Phil Carmody, Jul 19, 2009, in forum: C Programming
    Replies:
    77
    Views:
    1,652
    David Thompson
    Aug 3, 2009
  4. Jeremy
    Replies:
    1
    Views:
    410
    John Saunders [MVP]
    Jul 18, 2007
  5. Kaldrenon
    Replies:
    3
    Views:
    164
    Sebastian Hungerecker
    Jul 17, 2007
Loading...

Share This Page