How will I determine the rep for repInvariant? and How to write an abstract function?

I'm not sure what you mean by the first question, but I can answer the second.

An abstract function is one that defines a method signature without its body so that it can be overridden in any extending implementing class. I'm not sure which programming language you are using but I will demonstrate with a C# example.

// our base class must be abstract since it will contain an abstract function
public abstract class BaseClass
{
    // this function is abstract
    // it has a signature that says it takes no parameter but returns a boolean value
    public abstract bool foo();
}

// now for an implementing class that extends the base class
public class ImplementingClass : BaseClass
{
    // we override the abstract function from the base class
    public override bool foo()
    {
        return true;
    }
}

// let's do another implementation so we can show the real power later
public class AnotherImplementingClass : BaseClass
{
    // again, we override the abstract function
    public override bool foo()
    {
        return false;
    }
}

static void Main(string[] args)
{
    BaseClass first = new ImplementingClass();
    BaseClass second = new AnotherImplementingClass();
    BaseClass[] list = new BaseClass[] { first, second };

    foreach (BaseClass bc in list)
    {
        MessageBox.Show(bc.foo().toString()); // shows true the first time and false the second time
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.