06.01.2015 Views

IMPARARE IL C++ in 6 ore? - INFN

IMPARARE IL C++ in 6 ore? - INFN

IMPARARE IL C++ in 6 ore? - INFN

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Funzioni:def<strong>in</strong>izioni<br />

Funzione prototipo e’ uno statement ( ; ) che consiste: del tipo del<br />

val<strong>ore</strong> che ritorna la funzione, del nome e della lista dei parametri<br />

che entrano<br />

es. long Area(<strong>in</strong>t base,<strong>in</strong>t altezza=20); //20 e’ un default qualora<br />

//non immetti l’altezza nell’implementazione<br />

Def<strong>in</strong>izione di funzione:consiste di un header e del corpo della funzione<br />

stessa.<br />

Header:=prototipo con I parametri che devono avere un nome e non ci<br />

sono ( ; ) (vedi il primo esempio più complicato all’<strong>in</strong>izio).<br />

Es.<br />

Long Area(long l,long h) //puoi passare come argomenti<br />

{ //anche altre funzioni o se stessa<br />

return l*h;<br />

//(recursione)<br />

}

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

Saved successfully!

Ooh no, something went wrong!