abstract base class and class members
H. S. Teoh
hsteoh at quickfur.ath.cx
Sun Mar 4 10:22:47 PST 2012
On Sun, Mar 04, 2012 at 06:22:47PM +0100, Timon Gehr wrote:
> On 03/04/2012 06:16 PM, David wrote:
> >Is this intended behaviour? http://ideone.com/xrvvL
> >
> >shouldn't the 2nd writeln print the same as the first, well at least the
> >same content of i?
>
> This is intended behaviour. You have two distinct definitions of i.
> If you want to set i to 2 in the derived class, do so in the class
> constructor.
Yeah, only member functions can be overridden in the derived class (and
even then, D requires you to explicitly state that with the 'override'
keyword).
Makes one wonder, though... from an OO perspective, does it make sense
to have overridable non-function members? What semantics would (should)
that have?
T
--
"Life is all a great joke, but only the brave ever get the point." -- Kenneth Rexroth
More information about the Digitalmars-d-learn
mailing list