• Register

Invalid use of incomplete type is a compile time error. When we compile a C++ program using GCC, we are getting an error message similar to this invalid use of an incomplete type.

 

Problem

There can be more feasible issues which can cause this error but mainly this error is caused because the GCC compiler cannot find the full declaration of the given struct or class.

 

Solution

There is a high probability that you are missing an #include section. To resolve this issue, try to find out in which header file is responsible for the declaration. For example, if an error mentions any class, then look for the class in your program. Since normally classes have taken up space in header files that are similar to their name.

For example Myclass might reside in Myclass.h , Myclass.hxx 

So make sure to look out for these files. If you are unable to find out the origin of the error, then feel free to google // c++ missing type // there is a high probability that you might find out where it is located then you can put the header file accordingly. 

And also don’t forget to put the header file before the class, sometimes this silly mistake can also lead us to the error that wasn’t expected.

 

Example

If you want to look at a proper example then you can check out this post https://stackoverflow.com/questions/20013901/im-getting-an-error-invalid-use-of-incomplete-type-class-map

posted Jul 9 in c++ 100 points