hiding a class property behind a method
Ali Çehreli
acehreli at yahoo.com
Sat Feb 22 12:35:43 PST 2014
On 02/22/2014 12:06 PM, Nynn007 wrote:
>> The code uses the two objects through the A interface and x() is a
>> virtual function on that interface.
> [...]
>> Ali
I agree. :)
>
> The book "Programming in D" (r651) says in chapter "57.7 Using the
> subclass in place of the superclass", in the example about Clock and
> AlarmClock :
>
> void use(Clock clock) { ... }
> (sic) "In other words, although use() uses the object as a Clock, the
> actual object may be an inherited type that behaves in its own special
> way".
I obviously agree with that as well. :)
>
> Should'nt we understand that the first object is a B, the second object
> is a C and then should both behave like a B and a C, not like two A ?
You are correct. What I meant above is that the code uses the two object
as two As, which involves the "interface" of A. The behaviors may be
different.
Ali
More information about the Digitalmars-d-learn
mailing list