Test these Program A problem is found. Code The program can use:
Using system;
Static class M
{
Static void main ()
{
Point Rp = new rectpoint (12, 15 );
RP. Show ();
}
}
Class Point
{
Protected int m_x;
Protected int m_y;
Public Virtual void show ()
{
Console. writeline ("x =" + m_x.tostring () + "Y =" + m_y.tostring ());
}
}
Class rectpoint: Point
{
Public rectpoint (INT x0, int y0)
{
M_x = x0;
M_y = y0;
}
Public override void show ()
{< br> console. writeline ("rect:");
base. show ();
}< BR >}< br> the problem is from row 7th: Point Rp = new rectpoint (12, 15 );, I think the correct method should be rectpoint Rp = new rectpoint (12, 15); but when copying code, the point is not changed to rectpoint, but the program runs normally, the running result is the show of rectpoint. This problem was discovered later. Can an object be defined as its parent class? After the definition is complete, although it executes all the code of the subclass, the compiler will not allow the new sub-classes to pass, that is, the object can only execute the member functions of the parent class.