Question

I don't know whats going wrong with following code.

#ifndef LLIST_H_INCLUDED
#define LLIST_H_INCLUDED
// header content goes here

typedef int Element_Type;

struct LinkNode;

typedef LinkNode * Node_Ptr;

struct LinkNode
{
    Element_Type data_member;
    Node_Ptr    link_member; 
};

#endif

I made a header file of above code and place that file in "include" directory. But whenever I am trying to compile code, it fires following two errors.

1. , expected
2. Declaration missing ;

Edit

Another approach I used is

typedef int Element_Type;

struct LinkNode
{
    Element_Type data_member;
    LinkNode * link_member;
}* node_Ptr;

This fires declaration expected ; at line LinkNode * link_member line

enter image description here

Any help would be greater pleasure.

Was it helpful?

Solution

struct LinkNode  
{  
    Element_Type data_member;  
    struct LinkNode * link_member;  
}* node_Ptr;

This should fix it. (NOTE: It's possible that TurboC++ is more restrictive on dealing with structs than other C++ compilers (like g++). It seems to be evaluating them more strictly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top