abstract class question

  • Thread starter Thread starter Victor Fees
  • Start date Start date
V

Victor Fees

If I take an abstract class, as shown:

public abstract class PMData
{
public abstract void Save();
}


and then create an inherited class, such as:

public class Property : PMData
{

public override void Save()
{
return;
}
}


In other code, when I instantiate Property, the intellisense in Visual
Studio 2003 allows me to choose between PMData.Save() and Property.Save().
Choosing one or the other doesn't appear to affect the result of the code .
.. . but for some reason, I just didn't think that PMData.Save() would
really be an option when I instantiate Property.

Anyone have any input on this?

-Victor
 
I don't understand why intellisense does that either.

Polymorphism determines which class's implementation gets called at runtime.
 
Victor... It does not matter if you call the base class method or the
subclass method, the "proper" method will be called at runtime due to
polymorphism. More explanation at:

http://www.geocities.com/jeff_louie/OOP/oop4.htm

abstract class Drawable
{
    public abstract String DrawYourself();
}
class Circle : Drawable
{
    public override String DrawYourself()
    {
        return "Circle";
    }
}
class Square : Drawable
{
    public override String DrawYourself()
    {
        return "Square";
    }
}

http://www.geocities.com/jeff_louie/OOP/oop9.htm

// an interface version of Drawable
interface IDrawable
{
void DrawYourself();
}
class Circle : IDrawable
{
public void DrawYourself()
{
System.Console.WriteLine("Circle");
}
}

class Square : IDrawable
{
public void DrawYourself()
{
System.Console.WriteLine("Square");
}
}


Regards,
Jeff
In other code, when I instantiate Property, the intellisense in Visual
Studio 2003 allows me to choose between PMData.Save() and
Property.Save().<
 
Back
Top