Web Log di Adrian Florea

"You know you've achieved perfection in design, not when you have nothing more to add, but when you have nothing more to take away." Antoine de Saint-Exupery
posts - 440, comments - 2715, trackbacks - 3944

My Links

Archives

Post Categories

Image Galleries

.RO Blogs

.RO People

.RO Sites

Blogs

Furls

Links

vinCitori

[OT] Interfacce con costruttori di istanza in PHP 5.2.0

Via questo post di Kevin Williams, scopro che PHP, a partire dall'ultima versione (5.2.0), supporta "constructors in interfaces to force constructor signature checks in implementations". Si potrebbe quindi scrivere:

<?php
interface IFoo {
    public function __construct ();
}

class Foo implements IFoo {
    public function __construct () {
        echo "Ciao!\n";
    }
}
?>

Senza il costruttore della classe Foo, avremmo ottenuto l'errore: "Class Foo contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (IFoo::__construct)".

Come avevo gia' scritto in questo vecchio post, il CLR non consente costruttori di istanza nelle interfacce (costruttori static invece, si').

Print | posted on venerdì 29 dicembre 2006 23:05 | Filed Under [ Carillon .NET Varie ]

Powered by:
Powered By Subtext Powered By ASP.NET