Overloading Class Functions

Joe

Administrator
Staff member
The parent class has Setup() and Process() functions. They are simply overloaded in the child class.
FoxPro:
define class Parent as Custom
    function Setup                && setup your requirements and other inits here
        return .T.
    endfunc
    function Process            && do whatever it is you need to do!
        return .T.
    endfunc

define class Child as Parent 
    function Setup                && setup your requirements and other inits here
        return This.RequireField("clm_id")
    endfunc
    function Process   
        && lots of code here...
    endfunc
Notice the 'virtual' keyword in the parent class and 'override' in the child for the same effect:
Code:
public class Parent 
{
    public virtual bool Setup() // setup your requirements and other inits here
    {
        return true;
    }
    public virtual bool Process()// do whatever it is you need to do!
    {
        return true;
    }
}
public class Child : Parent 
{
    public override bool Setup()// setup your requirements and other inits here
    {
        return RequireField("clm_id");
    }
    public override bool Process()
    {        //lots of code here...
    }
}
 
Last edited:
Top