View Single Post
Old 12-12-2013, 00:03   #6
marco.r
Senior Member
 
Iscritto dal: Dec 2005
Città: Istanbul
Messaggi: 1817
Quote:
Originariamente inviato da vendettaaaaa Guarda i messaggi
Ciao,
stavo facendo esercizi presi da un corso che usa il C come linguaggio. Ad un certo punto c'era
Codice:
typedef struct Elem { int x; int y; struct Elem *next; } Punto;
typedef Punto * Linea;
(Disclaimer: sto partendo per la tangente ... )
Non e' una critica a te, perche' mi par di capire che il testo ti e' stato dato, ma nel codice e' importante quanto e forse piu' che nella lingua normale usare i termini corretti.
In sole due righe l'autore del testo e' riuscito a fare un sacco di confusione: il Punto e' un punto e una lista concatenata contemporaneamente, mentree una linea e' un puntatore a punti... che vuol dire ?!?!
Perche' non scrivere le cose per come stanno ? (uso una notazione C++ perche' e' quella del thread, ma il discorso e' analogo in C)
Codice:
struct Punto { int x; int y; };
struct Lista { Punto p; Lista* next; };
typedef Lista Linea;
Adesso non occorre piu' specificare "a voce" come e' fatto un punto, che Lista e' una lista concatenata e che una linea e' una lista di punti.
__________________
One of the conclusions that we reached was that the "object" need not be a primitive notion in a programming language; one can build objects and their behaviour from little more than assignable value cells and good old lambda expressions. —Guy Steele
marco.r è offline   Rispondi citando il messaggio o parte di esso
 
Hardware Upgrade Forum Database Error
Database Error Database error
The Hardware Upgrade Forum database has encountered a problem.

Please try the following:
  • Load the page again by clicking the Refresh button in your web browser.
  • Open the www.hwupgrade.it home page, then try to open another page.
  • Click the Back button to try another link.
The www.hwupgrade.it forum technical staff have been notified of the error, though you may contact them if the problem persists.
 
We apologise for any inconvenience.