fbpx
Welcome, Guest
Username: Password: Remember me
Visual Objects

Please use this forum to post questions about Visual Objects and Vulcan.NET
  • Page:
  • 1

TOPIC: Can Overloading be switched off?

Can Overloading be switched off? 1 year 10 months ago #2330

  ArneOrtlinghaus's Avatar Topic Author ArneOrtlinghaus Offline Posts: 126
Different times I have inserted errors using virtual methods and unintentionally writing parameters with different types compared to the basic object method.
The compiler treats this as an overloaded method. This is correct behavior, but it is not what I originally intended looking at the framework of classes we are using. When calling the method late bound a runtime error is happening. Also the original method is not overridden as I intended to do.

Overloading can be a nice feature, it only interferes sometimes with virtual method design.
What could be nice to have an additional compiler switch for the assembly to be able to choose using virtual without overloading or overloading without virtual methods - or having both knowing that parameters must be verified correctly.

Arne

Please Log in or Create an account to join the conversation.

Can Overloading be switched off? 1 year 10 months ago #2333

  robert's Avatar robert Offline Posts: 994
Arne,

"Virtual Methods" are not enabled by default. Most likely you have the language option "All instance methods virtual" enabled.
If you disable this option then you can control yourself which methods are virtual and which not by using the VIRTUAL keyword and/or OVERRIDE keyword.
CLASS Parent
VIRTUAL METHOD Speak AS VOID
Console.WriteLine("Parent")
END CLASS

CLASS Child INHERIT Parent
OVERRIDE METHOD Speak AS VOID
Console.WriteLine("Child")
END CLASS

Robert
XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1