Your teacher did not "defined a pointer that points to a struct TipoCelula
" he named a symbol for the type struct TipoCelula*
using typedef
.
Stay tuned, statement is not the same thing as definition!
The typedef
is very useful to give symbolic names for data types.
To better understand what happens, we will "remove" the typedefs
of your code, it would look something like this:
struct Item
{
int Chave;
};
struct Celula
{
struct Item item;
struct Celula * Prox;
};
struct Lista
{
struct Celula * Primeiro;
struct Celula * Ultimo;
};
Now, let’s create symbolic names for each of the structures defined using typedef
, only that way separate, rewriting everything would look something like:
typedef struct Item TipoItem;
typedef struct Celula TipoCelula;
typedef struct Lista TipoLista;
struct Item
{
int Chave;
};
struct Celula
{
TipoItem Item;
TipoCelula * Prox;
};
struct Lista
{
TipoCelula * Primeiro;
TipoCelula * Ultimo;
};
Pointers to types can also be named symbolically using typedef
, this is one of the techniques used by your teacher that you were not able to understand, look at this:
typedef struct Item TipoItem;
typedef struct Celula TipoCelula;
typedef struct Lista TipoLista;
typedef struct TipoCelula* TipoApontadorCelula;
struct Item
{
int Chave;
};
struct Celula
{
TipoItem Item;
TipoApontadorCelula Prox;
};
struct Lista
{
TipoApontadorCelula Primeiro;
TipoApontadorCelula Ultimo;
};
But in this definition of functions, Tipolista is a pointer struct, so what differentiates these two definitions of functions: void Flvazita(Typolista *Lista); int Empty(Tipolista Lista);
– Kaike Wesley Reis
I didn’t see any definition of function there.
TipoLista
is a two-member structure, both are the typeTipoApontador
(I find these names horrible).– Maniero