reference to an interface

Chris Nicholson-Sauls ibisbasenji at gmail.com
Mon Apr 10 13:25:25 PDT 2006


Quite actually, as I believe we have return type covariance for interfaces, you can in 
fact define the factory method in the interface.

# interface IFoo {
#   IFoo make () ;
#
#   bool doSomething () ;
# }

# class MyFoo : IFoo {
#   MyFoo make () { /* stuff */ } // note the return type; a MyFoo 'Is A' IFoo
#
#   protected this () { /* stuff */ }
#
#   bool doSomething () { /* stuff */ }
# }

-- Chris Nicholson-Sauls



More information about the Digitalmars-d-learn mailing list