Results 1 to 3 of 3

Thread: Inheritance Question

Threaded View

  1. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    Re: Inheritance Question

    Actually Constructors are the only thing not passed to a derived class. So it would inherit the interface but not the constructors. You can call them as you show but you will need to write that code it is not implied via inheritance.

    Nevermind I guess it does inherit and fire the parent classes default constructor but it doesn't inherit any of the non default constructors.

    So calling New on your child class will use the New on the parent class the same as:
    VB Code:
    1. Public Sub New()
    2. Mybase.New()
    3. End Sub

    But the child class will not have the other constructors through inheritance.

    VB Code:
    1. Public Class Parent
    2.  
    3.     Public Sub New()
    4.         MsgBox("Showing")
    5.     End Sub
    6.  
    7.     Public Sub New(ByVal msg As String)
    8.         MsgBox(msg)
    9.     End Sub
    10.  
    11. End Class
    12.  
    13. Public Class Child
    14.     Inherits Parent
    15.  
    16. End Class
    17.  
    18. 'syntax of use
    19.         Dim c As New Child 'only default constructor is available
    Last edited by Edneeis; May 11th, 2005 at 10:26 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width