473,849 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What is "incomplete type?" (compiler error)

g++ compiler error question.

I have a container C whose constructor takes a class B that is inherited
from an abstract class A. So I have the line of code:

B binstance;
C cinstance(binst ance);
The compiler gives the error,

error: variable `C cinstance' has initializer but incomplete type

I am trying to figure out what this means. What's an incomplete type?
I have all the methods that were abstract in A explicitly in B. I have
done this before with other classes inherited from the same abstract
class A and had no problems. Never seen this error before. What the
heck is going on? Any information will be greatly appreciated. I am
stuck. Thanks.

-- Lou Pecora (my views are my own) REMOVE THIS to email me.
Jul 23 '05 #1
5 33776

"Lou Pecora" <pe**********@T HISanvil.nrl.na vy.mil> wrote in message
news:pe******** *************** *********@ra.nr l.navy.mil...
g++ compiler error question.

I have a container C whose constructor takes a class B that is inherited
from an abstract class A. So I have the line of code:

B binstance;
C cinstance(binst ance);
The compiler gives the error,

error: variable `C cinstance' has initializer but incomplete type

I am trying to figure out what this means. What's an incomplete type?
I have all the methods that were abstract in A explicitly in B. I have
done this before with other classes inherited from the same abstract
class A and had no problems. Never seen this error before. What the
heck is going on? Any information will be greatly appreciated. I am
stuck. Thanks.


An incomplete type error occurs when you try to use a class (or struct) that
has not yet been fully defined, inside another class. Without seeing your
class definitions for B and C, it's impossible to tell what you're missing,
exactly. But...perhaps you're trying to pass the B object by value to the C
constructor, instead of by const reference as it more often done?

-Howard

Jul 23 '05 #2
In article <rc************ ********@bgtnsc 04-news.ops.worldn et.att.net>,
"Howard" <al*****@hotmai l.com> wrote:
"Lou Pecora" <pe**********@T HISanvil.nrl.na vy.mil> wrote in message
news:pe******** *************** *********@ra.nr l.navy.mil...
g++ compiler error question.

I have a container C whose constructor takes a class B that is inherited
from an abstract class A. So I have the line of code:

B binstance;
C cinstance(binst ance);
The compiler gives the error,

error: variable `C cinstance' has initializer but incomplete type

I am trying to figure out what this means. What's an incomplete type?
I have all the methods that were abstract in A explicitly in B. I have
done this before with other classes inherited from the same abstract
class A and had no problems. Never seen this error before. What the
heck is going on? Any information will be greatly appreciated. I am
stuck. Thanks.


An incomplete type error occurs when you try to use a class (or struct) that
has not yet been fully defined, inside another class. Without seeing your
class definitions for B and C, it's impossible to tell what you're missing,
exactly. But...perhaps you're trying to pass the B object by value to the C
constructor, instead of by const reference as it more often done?

-Howard


Thanks, Howard, for the reply.

I understand what you are saying. I pass B as a reference to A. That
is the C constructor is,

C::C(A &Ainst) { ... }

I have done this with this C class before, but I have written a new B
class inheriting from the same A I used before. But the compiler chokes
right where I try to declare a variable of type C with a B instance
passed to it in the declaration, i.e. C Cinst(Binst), and I am looking
for any clue why. I can see none, but there must be something undefined
for the compiler. I will go back and look, again. Thanks.

-- Lou Pecora (my views are my own) REMOVE THIS to email me.
Jul 23 '05 #3
Well, Duh (dope-slap upside my head), I found the answer to "incomplete
type." It is basically what others have said: some code is undefined.
I thought the header for my container code was included in another
header, but it wasn't only the declaration

class C;

was in that header. So including the container header got rid of the
"incomplete type?" error.

Mea culpa. And thanks to all who answered.

-- Lou Pecora (my views are my own) REMOVE THIS to email me.
Jul 23 '05 #4
Lou Pecora wrote:

I have a container C whose constructor takes a class B that
is inherited from an abstract class A. So I have the line of code:

B binstance;
C cinstance(binst ance);

The compiler gives the error,

error: variable `C cinstance' has initializer but incomplete type

I am trying to figure out what this means.


This means that C has been declared but not defined.
Here is a simpler example that gives the same error:

class C;

int main()
{
C c(1);
}

If you think C has been defined, then perhaps you have a
problem with #include dependencies.

Jul 23 '05 #5
In article <11************ *********@g43g2 000cwa.googlegr oups.com>,
"Old Wolf" <ol*****@inspir e.net.nz> wrote:
Lou Pecora wrote:

I have a container C whose constructor takes a class B that
is inherited from an abstract class A. So I have the line of code:

B binstance;
C cinstance(binst ance);

The compiler gives the error,

error: variable `C cinstance' has initializer but incomplete type

I am trying to figure out what this means.


This means that C has been declared but not defined.
Here is a simpler example that gives the same error:

class C;

int main()
{
C c(1);
}

If you think C has been defined, then perhaps you have a
problem with #include dependencies.


Thanks. I finally realized I goofed and did not include the C header.
I thought it was included in another header, but only

class C;

was declared. Mea Cupla!

-- Lou Pecora (my views are my own) REMOVE THIS to email me.
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1864
by: Mat DeLong | last post by:
Can someone explain this error to me? : main.cpp:9: instantiated from `void show(const LIST::List<T>&) ' main.cpp:23: instantiated from here list.cpp:58: error: dependent-name `LIST::List<T>::ListIterator' is parsed as a non-type, but instantiation yields a type .......... This is the first part of the main:
5
12336
by: kj | last post by:
Hi. I'm trying to compile some software from source, and I'm getting an error I can't figure out. The error in question is key_events.h:38: field `id' has incomplete type and the lines corresponding to the error are: struct kb_event_id_s { char name;
2
7681
by: Lenonardo | last post by:
Hi. I'm writing a VB.Net application to update multiple Excel Worksheets. I'm using late binding (i.e. all variables are objects + use createobject) I develop the application on an XP machine with Excel 2002 (version 10.0) installed - and the code works fine. I then test the code on a laptop running Excel 2000 (version 9.0) and it
3
6659
by: Ed L. | last post by:
On 7.4.6, is there any problem with defining one column of a view to be a string literal? For example ... $ psql -c "create view fooview as select 'bar' as footype" WARNING: column "footype" has type "unknown" DETAIL: Proceeding with relation creation anyway. CREATE VIEW Or is this warning just noise in this case?
6
10840
by: geoffrobinson | last post by:
Hi, I'm serializing an object using XmlSerializer. It is serializing, but we are getting errors upon deserialization. We use the following code to serialize: FileStream fs = new FileStream(NavCmdFile, FileMode.Create, FileAccess.Write, FileShare.None); XmlSerializer xmlFmt = new XmlSerializer(someObject.GetType());
3
11843
by: John Sasso | last post by:
In my Yacc .y file I defined: %union { int value; struct Symbol Sym; } The Symbol struct I defined in a header file I #included in the Prologue section of the .y file as:
3
2494
by: IR | last post by:
Hi, I've been trying to do the following (which doesn't compile) : template<class T, class F = Example<T struct Example { F foo(); };
5
2975
by: Charles Packer | last post by:
In the code example below, why does the reference to gdk_pixbuf_new_from_file in main compile okay, but in subr2 gives the error "dereferencing pointer to incomplete type"? A search through this newsgroup suggests that the error arises when the proper header files are missing, but when the header file I've got is sufficient to compile one instance of the call, but not the other, I don't know where to turn next.
5
3192
by: tejesh | last post by:
I am trying to compile the following code int backend_sm_run(struct interface_data *ctx) { xsup_assert((ctx != NULL), "ctx != NULL", TRUE); xsup_assert((ctx->statemachine != NULL), "ctx->statemachine != NULL", TRUE); backend_sm_check_globals(check);
0
9893
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10665
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10723
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10349
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7894
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5921
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4139
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3177
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.