2
Answers

NP44 constructor

Maha

Maha

17y
2k
1

Hi Guys

 

NP44   constructor

 

C# Corner article website address is given below. I wish to know what is the purpose of having public Shape() constructor in the Shape class. Because program is working well without this constructor. Please anyone knows explain.  

 

http://www.c-sharpcorner.com/UploadFile/pcurnow/polymorphcasting06222007131659PM/polymorphcasting.aspx

 

Thank you

 

public class Shape

{

    protected int m_xpos;

    protected int m_ypos;

 

    /*

    public Shape()

    {

    }

    */

    public Shape(int x, int y)

    {

        m_xpos = x;

        m_ypos = y;

    }

    public virtual void Draw()

    {

        Console.WriteLine("Drawing a SHAPE at {0},{1}", m_xpos, m_ypos);

    }

}

Answers (2)
Next Recommended Forum