Self-referential structs
Në shqip: Struct-et që tregojnë te vetja
ShpjegimiSQ
Një struct mund të ketë një pointer drejt një struct-i të të njëjtit lloj — kështu ndërtohen listat e lidhura dhe pemët. Duhet patjetër pointer, jo vetë struct-i (përndryshe do të ishte i pafund).
EnglishEN
A struct can hold a pointer to a struct of the same type — that's how linked lists and trees are built. It must be a pointer, not the struct itself (or it would be infinite).
Si ta mendosh
Si gjuetia e thesarit: çdo shënim të tregon ku është shënimi tjetër.
Lexoje në anglisht
Like a treasure hunt: each clue tells you where the next one is.
Shembull kodic
struct Nyje {
int vlera;
struct Nyje *majtas, *djathtas;
};