Friday, 6 September 2013

what is meant by forward declaration.. and difference between typedef struct X and struct X

what is meant by forward declaration.. and difference between typedef
struct X and struct X

i am a beginner in c programming.. and i know the difference between
struct type declaration and typedef struct declaration.. but i came across
to know an answer sying that if we define a struct like
typedef struct
{
some members;
}struct_name;
then it will be like providing an alias to an anonymous struct(as it is
not having a tag name).... and so it cant be used for forward
declaration.. it is a new term for me.. dont know what does the "forward
declaration mean"..
and also i wanted to know that for the following code,
typedef struct NAME
{
some members;
}struct_alias;
is there any difference between NAME and struct_alias?? or are both equal
as struct_alias is an alias of struct NAME ?
and furthermore can we declare a variable of type struct NAME like these:
struct_alias variable1;
and/or like:
struct NAME variable2;
or like:
NAME variable3; // ???

No comments:

Post a Comment