A
archana
Hi all,
I am confuse in concept of inheritance. I am having following 2
classes
class base1
{
public void abc()
{
System.Console.WriteLine("base1 abc");
}
public void pqr()
{
System.Console.WriteLine("base1 pqr");
}
public void xyz()
{
System.Console.WriteLine("base1 xyz");
}
}
class derived1 : base1
{
public void abc()
{
System.Console.WriteLine("derived1 abc");
}
public void pqr()
{
System.Console.WriteLine("derived1 pqr");
}
public void xyz()
{
System.Console.WriteLine("derived1 xyz");
}
}
so when i am having code like following
base1 c = new derived1();
c.abc();c.pqr();c.xyz();
Here what exactly happen. Will object of derived class gets created and
its reference gets stored into c? If yes, then if my derived class has
more mothod will those also get initialize and can i access those
methods of derived class through base class object?
Please correct me if i am wrong.
thanks in advance
I am confuse in concept of inheritance. I am having following 2
classes
class base1
{
public void abc()
{
System.Console.WriteLine("base1 abc");
}
public void pqr()
{
System.Console.WriteLine("base1 pqr");
}
public void xyz()
{
System.Console.WriteLine("base1 xyz");
}
}
class derived1 : base1
{
public void abc()
{
System.Console.WriteLine("derived1 abc");
}
public void pqr()
{
System.Console.WriteLine("derived1 pqr");
}
public void xyz()
{
System.Console.WriteLine("derived1 xyz");
}
}
so when i am having code like following
base1 c = new derived1();
c.abc();c.pqr();c.xyz();
Here what exactly happen. Will object of derived class gets created and
its reference gets stored into c? If yes, then if my derived class has
more mothod will those also get initialize and can i access those
methods of derived class through base class object?
Please correct me if i am wrong.
thanks in advance