07.06.2013 Views

Classi astratte ed interfacce - Dipartimento di Ingegneria Informatica ...

Classi astratte ed interfacce - Dipartimento di Ingegneria Informatica ...

Classi astratte ed interfacce - Dipartimento di Ingegneria Informatica ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A. Longheu – Linguaggi M-Z – Ing. Inf. 2009-2010<br />

<strong>Classi</strong> <strong>ed</strong> Interfacce innestate<br />

La classe interna può adombrare campi e/o meto<strong>di</strong> della classe<br />

contenitrice semplicemente sovrascrivendoli<br />

Una classe interna può però anche nascondere membri della<br />

classe contenitrice se er<strong>ed</strong>ita omonimi da qualche altra classe, ad<br />

esempio:<br />

class Uno {<br />

int x;<br />

class Due extends Tre {<br />

void increment () { x++; }<br />

}<br />

}<br />

class Tre { int x; }<br />

la x su cui opera Due non è quella <strong>di</strong> Uno ma quella <strong>di</strong> Tre;<br />

occorre in tal caso evitare il problema o utilizzare riferimenti<br />

espliciti, tipo this.x o Uno.this.x<br />

40

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!