It depends on whether you want to be able to call both versions of the
overload from a base class reference or just the one without parameters. In
either case it's not difficult
Case 1:
public class Foo
{
public virtual void Bar() {...}
}
public class Foo2 : Foo
{
public override void Bar() {...}
public void Bar(int i) {...}
}
In this case we could call Bar() from a reference to Foo or Foo2 but I could
only call Bar(int i) from a reference to Foo2. This is the most common
scenario because you normally won't know what paramater(s) the overload in
the derived class will need when declaring the base class.
Case 2:
public class Foo
{
public virtual void Bar() {...}
public virtual void Bar(int i) {...}
}
public class Foo2 : Foo
{
public override void Bar() {...}
}
public class Foo3 : Foo
{
public override void Bar(int i) {...}
}
public class Foo4 : Foo
{
public override void Bar() {...}
public override void Bar(int i) {...}
}
In this case we declare both overloaded methods in the base class, then the
derived classes can choose to override 0, 1 or both of the methods.
--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
http://msmvps.com/windsor/
"juli jul" <ju******@yahoo.com> wrote in message
news:u0***************@TK2MSFTNGP09.phx.gbl...
Hello,
I have a function in base class and a lot of child classes of it. Couple
of them need an input argument in this function and all the other don't.
How can I do it using ovveride and virtual?
Thank you!
*** Sent via Developersdex http://www.developersdex.com ***