l struct point rect 1 int x int

  • Slides: 13
Download presentation

Εμφωλιασμένες Δομές l Δομές ως μέλη άλλων δομών είναι επιτρεπτά: struct point { rect

Εμφωλιασμένες Δομές l Δομές ως μέλη άλλων δομών είναι επιτρεπτά: struct point { rect 1 int x; int y; topleftcorner x }; struct rectangle { struct point topleftcorner; struct point bottomrightcorner; } rect 1; l y bottomrightcorner x y Πρόσβαση με διαδοχικές τελείες (. ) rect 1. topleftcorner. x = 10; l Παίρνουμε το πεδίο x του πεδίου topleftcorner της μεταβλητής rect 1 ΜΑΘ 106/3122 – Γλώσσα Προγραμματισμού 7 Ξ. Ζαμπούλης

struct employee new. Employee (char *name, char *pos, char *id, double sal, int y)

struct employee new. Employee (char *name, char *pos, char *id, double sal, int y) { struct employee new. E; strcpy(new. E. title, name); strcpy(new. E. position, pos); strcpy(new. E. id, id); new. E. salary = sal; new. E. years = y; return new. E; } ΜΑΘ 106/3122 – Γλώσσα Προγραμματισμού 10 Ξ. Ζαμπούλης