Re: Sub class constructor
From: MN (1[n.m-recrut1]at2[ifrance2]dot3[com3])
Date: 12/23/04
- Next message: Cor Ligthert: "Re: "" and Nothing"
- Previous message: Cor Ligthert: "Re: "" and Nothing"
- In reply to: JC Voon: "Sub class constructor"
- Next in thread: Herfried K. Wagner [MVP]: "Re: Sub class constructor"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 23 Dec 2004 10:00:25 +0100
If you want to use parent constructors when instanciating your child class,
you need to implement the 3 constructors in your child class and call parent
constructor from it;
public class Parent
public sub New()
MyBase.New
...
end sub
public sub New(i as integer)
MyBase.New(i)
...
end sub
public sub New(i as integer, s as string)
MyBase.New(i, s)
...
end sub
...
end class
Note that when you instantiate a class, you are calling the class
constructors not parent class constructor;
Regards.
"JC Voon" <jcvoon_99@yahoo.com> a écrit dans le message de news:
41ca75fa.25514988@msnews.microsoft.com...
> Hi:
>
> The parent class have 3 version of constructor:
>
> public class Parent
> public sub New()
> end sub
>
> public sub New(i as integer)
> myclass.New()
> ...
> end sub
>
> public sub New(i as integer, s as string)
> myclass.New()
> ...
> end sub
> end class
>
>
> public class Child
> inherits Parent
>
> end class
>
>
> When i try to create the Child object, i can only use the New() as a
> constructor, the others 2 constructor is not accessable, what am i
> missing ?
>
> Thanks
> JCVoon
>
>
>
>
>
>
- Next message: Cor Ligthert: "Re: "" and Nothing"
- Previous message: Cor Ligthert: "Re: "" and Nothing"
- In reply to: JC Voon: "Sub class constructor"
- Next in thread: Herfried K. Wagner [MVP]: "Re: Sub class constructor"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|