www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - overriding methods

reply stunaep <admin pea2nuts.com> writes:
I get a deprecation warning with  Override, but I was unable to 
find the proper way to do it.
Am I meant to add override before the method like this?
override public void startThread(Thread t, int pri) {
    ...
}
Am I meant to wrap the entire method in override { } like this?
 override {
    public void startThread(Thread t, int pri) {
        ...
    }
 }
Both of them compile, so I'm wondering which to use. Is override {} supposed to be for adding multiple methods inside to avoid writing override before each method, or is putting override in front of the method without brackets just wrong?
Apr 05 2016
parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Tuesday, 5 April 2016 at 18:38:43 UTC, stunaep wrote:
 I get a deprecation warning with  Override, but I was unable to 
 find the proper way to do it.
What error message exactly are you getting and on what code? Both styles you put there should work equally well.
Apr 05 2016
parent reply stunaep <admin pea2nuts.com> writes:
On Tuesday, 5 April 2016 at 18:42:33 UTC, Adam D. Ruppe wrote:
 On Tuesday, 5 April 2016 at 18:38:43 UTC, stunaep wrote:
 I get a deprecation warning with  Override, but I was unable 
 to find the proper way to do it.
What error message exactly are you getting and on what code? Both styles you put there should work equally well.
I had no error on the examples I posted, only when using Override previously. It just says to use override attribute instead of Override source\game\client.d(8,20): Deprecation: implicitly overriding base class method game.GameWindow.startThread with game.client.Client.startThread deprecated; add 'override' attribute source\game\client.d(7,3): Error: undefined identifier 'Override'
Apr 05 2016
next sibling parent Adam D. Ruppe <destructionator gmail.com> writes:
On Tuesday, 5 April 2016 at 18:54:39 UTC, stunaep wrote:
 I had no error on the examples I posted, only when using 
  Override previously. It just says to use override attribute 
 instead of  Override

 source\game\client.d(8,20): Deprecation: implicitly overriding 
 base class method game.GameWindow.startThread with 
 game.client.Client.startThread deprecated; add 'override' 
 attribute
 source\game\client.d(7,3): Error: undefined identifier 
 'Override'
Yeah, that just means use the override keyword on the method. There is no Override thing, it is a plain lowercase keyword.
Apr 05 2016
prev sibling next sibling parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 04/05/2016 11:54 AM, stunaep wrote:

 when using  Override previously. It just says to use override
 attribute instead of  Override
 source\game\client.d(7,3): Error: undefined identifier 'Override'
Note that it doesn't say _instead of Override_. Override is an undefined symbol in your code. Override is user defined attribute (UDA) syntax. The programmer is responsible for defining the semantics of user defined attributes. Ali
Apr 05 2016
prev sibling parent pineapple <meapineapple gmail.com> writes:
On Tuesday, 5 April 2016 at 18:54:39 UTC, stunaep wrote:
 I had no error on the examples I posted, only when using 
  Override previously. It just says to use override attribute 
 instead of  Override
Unlike in Java, D's override indicator doesn't look like an annotation, it's just a keyword placed before a method along the same lines as "static" or "public" or "protected".
Apr 05 2016