error: pointer to incomplete class type is not allowed

dato datuashvili picture dato datuashvili · Mar 11, 2012 · Viewed 18.4k times · Source

I am stumped at this step while implementing a ternary tree:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

typedef struct tnode *Tptr;
    typedef struct node
{
    char splitchar;
    Tptr lokid,eqkid,hikid;

}Tnode;

int research(Tptr p,char *s)
{
    if (!p) return 0;
    if (*s<p->
}

int main(){
    return 0;
}

When I move the mouse icon near the p, it shows me a red color and error:

pointer to incomplete class type is not allowed

My question is exactly what is an incomplete class? Please help me, thanks.

Answer

Jurlie picture Jurlie · Mar 11, 2012

incomplete class (or type) is the type that is forward declared, but is not defined. Just like your tnode. Probably you should replace node by tnode as the tag of structure in your example to get what you need.