dunque...
mi ritrovo a dover scrivere n funzioni (con n -> infinito) tutte del tipo
dove ogni volta cambia solo il nome della funzione è l'ultima riga...Codice PHP:
function ottieni_pf($pos) {
$temp = $this->testa;
$i = 0 ;
while($temp != null && $i < $pos)
{
$i++;
$temp = $temp->pun;
}
if($temp == null)
return null;
return $temp->ottieni_pf();
}
function ottieni_morto($pos) {
$temp = $this->testa;
$i = 0 ;
while($temp != null && $i < $pos)
{
$i++;
$temp = $temp->pun;
}
if($temp == null)
return null;
return $temp->ottieni_morto();
}
function ottieni_oro($pos) {
$temp = $this->testa;
$i = 0 ;
while($temp != null && $i < $pos)
{
$i++;
$temp = $temp->pun;
}
if($temp == null)
return null;
return $temp->ottieni_oro();
}
esiste per caso un meccanismo simile al c++ che permette di definire qualcosa simile alle funzioni template??