Vuhelper
10-25-2011, 10:59 PM
Q1 [Marks: 10]
How can you define a pair of mutually referential structures? Consider the following code
typedef struct {
int afield;
BPTR bpointer;
} *APTR;
typedef struct {
int bfield;
APTR apointer;
} *BPTR;
But the compiler doesn't know about BPTR when it is used in the first structure declaration.
Q2 [marks: 10]
How can you declare a function that can return a pointer to a function of the same type? If you are building a state machine with one function for each state, each of which returns a pointer to the function for the next state.
How can you define a pair of mutually referential structures? Consider the following code
typedef struct {
int afield;
BPTR bpointer;
} *APTR;
typedef struct {
int bfield;
APTR apointer;
} *BPTR;
But the compiler doesn't know about BPTR when it is used in the first structure declaration.
Q2 [marks: 10]
How can you declare a function that can return a pointer to a function of the same type? If you are building a state machine with one function for each state, each of which returns a pointer to the function for the next state.