shouldn't override be obligatory?

div0 div0 at users.sourceforge.net
Sun Mar 14 08:11:59 PDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Trass3r wrote:
> so you don't accidentally override a base class method without knowing it.

use -w:

import std.stdio;

class A
{
  void  foo()  { writeln("A.foo"); }
}

class B : A
{
  void  foo()  { writeln("B.foo"); }
}

void main()
{
  A  a = new B;
  a.foo();
}

>
warning - test.d(10): Error: overrides base class function test.A.foo,
but is not marked with 'override'

I never compile without -w

Strangely it doesn't give an error if A is an interface though.

- --
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFLnPy/T9LetA9XoXwRAu29AKCKx4fRYE1OYFQmW9wBZ7Gs+orDzQCgghKz
Q8pGjo99BzqrP0819h7p9yM=
=QVzI
-----END PGP SIGNATURE-----



More information about the Digitalmars-d mailing list