I have the following classes:
class Polygon
{
protected string name;
protected float width, height;
public Polygon(string theName, float theWidth, float theHeight)
{
name = theName;
width = theWidth;
height = theHeight;
}
public virtual float calArea()
{
return 0;
}
}
class Rectangle : Polygon
{
public Rectangle(String name, float width, float height) : base(name,width,height)
{
}
public override float calArea()
{
return width * height;
}
}
Main function1:
static void Main(string[] args)
{
Rectangle rect1 = new Rectangle("Rect1", 3.0f, 4.0f);
float Area = rect1.calArea()
}
Main function2:
static void Main(string[] args)
{
Polygon poly = new Rectangle("Rect1", 3.0f, 4.0f);
float Area = poly.calArea()
}
I understand that Main function 2 uses dynamic binding.
If I change the override keyword to new in calArea method of Rectangle class, then it is static binding.
What about main function 1? Does it use static/dynamic binding?