Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective C - Using typedef struct in header file

I am trying to create a LinkedList in Objective C.

In the .h file I am trying to create a Node using the code:

@interface AALinkedList : NSObject
{
    typedef struct Node
    {
        int data;
        struct Node *next;
    } Node;
}

This gives me an error saying Type name does not allow storage class to be specified

What does this mean ? and how do I fix it ?

like image 743
Ashish Agarwal Avatar asked May 23 '26 19:05

Ashish Agarwal


1 Answers

typedef struct Node {
    int data;
    Node *next;
} Node;

@interface AALinkedList : NSObject
{
    Node node;
    // or Node *node;
}
like image 133
user3125367 Avatar answered May 26 '26 10:05

user3125367



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!