Forums

How do I override protected members?

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

How do I override protected members?

Postby gauthier » Sun Dec 07, 2008 11:17 am

How do you declare protected override members?
class Base
get a as String is protected
return "a"

class Inherited
inherits Base
get a as String is override
return "b"


gives
Code: Select all
error: "Sub.A": cannot change access modifiers when overriding "protected" inherited member "Base.A"
warning: (Location of symbol related to previous error)
Compilation failed - 1 error, 1 warning


class Base
get a as String is protected
return "a"

class Inherited
inherits Base
get a as String is protected override
return "b"


gives

Code: Select all
error: Expecting EOL, but got "override" instead.
Compilation failed - 1 error, 0 warnings


Thanks for your help
gauthier
 
Posts: 116

Re: How do I override protected members?

Postby Charles » Sun Dec 07, 2008 12:48 pm

Put commas in between like it's a list.
...is protected, override
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: How do I override protected members?

Postby gauthier » Sun Dec 07, 2008 1:09 pm

Thank you, I just added a page on the wiki if of any use:

http://cobra-language.com/trac/cobra/wi ... erModifier
gauthier
 
Posts: 116

Re: How do I override protected members?

Postby Charles » Sun Dec 07, 2008 1:11 pm

Thanks. I also added a ticket so that in the future, the Cobra compiler will tell you.

http://cobra-language.com/trac/cobra/ticket/87
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: How do I override protected members?

Postby gauthier » Sun Dec 07, 2008 1:37 pm

Thanks, indicative error messages are a major feature for the compiler, and cobra is already quite helpfull at this :)
gauthier
 
Posts: 116


Return to Discussion

Who is online

Users browsing this forum: No registered users and 44 guests