We help IT Professionals succeed at work.

Overload Question...

Mike Eghtebas
on
337 Views
Last Modified: 2012-06-27
I have a question regarding parameters and data type of a sub. I understand that the data type of parameters could be different (of course this is the main reason we overload, or isn’t it?).

Question: Do we have the same number of parameters in overload?

Some explanation with a sample will be appreciated.

Thank you.
Comment
Watch Question

Paul JacksonSoftware Engineer
CERTIFIED EXPERT
Top Expert 2011
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Mohamed AbowardaSenior Software Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Mike EghtebasDatabase and Application Developer

Author

Commented:
We generally ovrload a routine from a derived class or from client code. We are overloading a routine that we dont't have access to it (in it in base class or DLL).

Question: Based on setup above, if a routine as only two parameters and we are changing the number of overloaded routin in the base class, how that routin will be able to use the new parameter that didn't exist before? Or what if instead of two parameter, the overload supplies only one parameter. How would the original routine function with a missing parameter?

Thanks,

Mike
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Mike EghtebasDatabase and Application Developer

Author

Commented:
CodeCruiser,

re:> Overloading is used to REPLACE the functionality

If so, then I have no further question on this.

Does Override do the same (replacing the routine in the base class) as well?

Thanks

Mike
Mike EghtebasDatabase and Application Developer

Author

Commented:
Hi Medo3337,

You have three examples of Overload:

Function GetWord() As String
Function GetWord(ByVal Position As Integer) As String
Function GetWord(ByVal Search As String) As String

Q1: Is Overload keyword optional? Are the lines below the same as what you have?

Overload Function GetWord() As String
Overload Function GetWord(ByVal Position As Integer) As String
Overload Function GetWord(ByVal Search As String) As String

Q2: Does overload exists in either in a derived class or client code?

Q3: Where is the code for code for "GetWord" to execute? In the base class or where it is called from?

Thank you.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.