Scott,
Of course, as Herfried pointed out constructors are NEVER inherited, it does
not make sense to inherit a constructor, as each class requires its own
constructor.
If you do not give a class a constructor one will be provided for you,
provided that your base class has a default constructor. The constructor
provided for you is called the default constructor and has no parameters.
If you provide your class with any constructors, the default constructor
will not be provided for you. In this case if you need a parameterless
constructor you need to provide it yourself.
Again each class requires its own constructor, except in the case of
providing a default (parameterless constructor) the compiler cannot and
should not attempt to decide what a constructor should look like, as the
designer of the class knows best what constructors the class needs!
This is all covered in the link I gave.
Thanks for the catch.
Jay
"Scott M." <s-***@badspamsnet.net> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
I've found though, that constructors are special and don't work the same
as other overloaded members. If you overload a constructor like this:
Public Class A
Public Sub New()
End Sub
Public Sub New(x as string)
End Sub
Public Sub new(y as integer)
End Sub
End Class
And then you make a new class (B) that inherits from "A", the overloaded
constructors won't be available. This is only the case with constructors,
do this overloading with any other class member and the overloaded
versions are available in the derived classes.
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in
message news:eC**************@TK2MSFTNGP12.phx.gbl... Stephen,
Constructors can be overloaded just like other methods, as long as the
parameter types are different.
Public Class SomeClass
Public Sub New()
End Sub
Public Sub New(ByVal i As Integer)
End Sub
Public Sub New(ByVal s As String)
End Sub
Public Sub New(ByVal ParamArray args() As String)
End Sub
End Class
You can even include optional parameters, however I normally favor
overloading to the Optional keyword.
As I stated in my other post, overloading constructors, base classes &
other OOP concepts are explained in Robin A. Reynolds-Haertle's book "OOP with
Microsoft Visual Basic .NET and
Microsoft Visual C# .NET - Step by Step" from MS Press covers this plus
the rest of OOP in VB.NET, in a very straight forward manner.
OOP concepts in VB.NET is also covered in this section of MSDN.
http://msdn.microsoft.com/library/de...ithObjects.asp
Of course you are welcome to ask in the newsgroups also.
Hope this helps
Jay
"Stephen Martinelli" <st*****@johnstontrading.com> wrote in message
news:eP**************@TK2MSFTNGP09.phx.gbl... thanks for the help...just one more question....
can a class have more then two parameterized constructors?..i would
like to be able to instanciate the class with a different number of
argument.....
thanks folks
steve