Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > invalid use of undefined type, .h file confusion

Reply
Thread Tools

invalid use of undefined type, .h file confusion

 
 
vfunc@talktalk.net
Guest
Posts: n/a
 
      02-11-2006
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?

 
Reply With Quote
 
 
 
 
Audison.Athena
Guest
Posts: n/a
 
      02-11-2006
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.

 
Reply With Quote
 
 
 
 
vfunc@talktalk.net
Guest
Posts: n/a
 
      02-11-2006
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.

 
Reply With Quote
 
vfunc@talktalk.net
Guest
Posts: n/a
 
      02-11-2006
what should the forward declaration of enbase look like ?

 
Reply With Quote
 
vfunc@talktalk.net
Guest
Posts: n/a
 
      02-11-2006
OK, thanks for the help. A case of thinking through what it looks like
to the compiler.

 
Reply With Quote
 
Audison.Athena
Guest
Posts: n/a
 
      02-11-2006
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.

 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      02-11-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) 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.
 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      02-11-2006
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.
 
Reply With Quote
 
vfunc@talktalk.net
Guest
Posts: n/a
 
      02-12-2006
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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Confusion about undefined behaviour Phil Carmody C Programming 77 08-03-2009 06:05 AM
Undefined Method confusion - Ruby Newbie (I know it rhymes, don't hurt me) Kaldrenon Ruby 3 07-17-2007 07:44 PM
typeof x == 'undefined' or x == undefined? -Lost Javascript 13 01-31-2007 12:04 AM
undefined vs. undefined (was: new Array() vs []) VK Javascript 45 09-12-2006 05:26 PM
undefined behavior or not undefined behavior? That is the question Mantorok Redgormor C Programming 70 02-17-2004 02:46 PM



Advertisments