using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CAInheritance_AbstractApp
{
class cParent // Parent Class
{
public int pubA;
private int priA;
protected int proA;
public cParent() //Default Constructor
{ }
public cParent(int a, int b, int c) :this() // Parameterized Constructor
{
this.pubA = a;
this.priA = b;
this.proA = c;
}
}
class cChild : cParent
{
public int pubB;
public cChild()
{ }
public cChild(int a, int b, int c,int d)
: base(a, b, c)
{
this.pubA = a;
this.proA = b;
//this.priA = c; private A connot accesble here because of its access level
this.pubB = d;
}
public void Foo()
{
cParent p = new cParent();
cChild c = new cChild();
proA = 10;
c.proA = 10;
//p.proA = 10; NotAllowed because it is accessble only through child
}
}
class Program
{
static void Main(string[] args)
{
cChild b = new cChild(1, 2, 3, 4);
b.Foo();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CAInheritance_AbstractApp
{
class cParent // Parent Class
{
public int pubA;
private int priA;
protected int proA;
public cParent() //Default Constructor
{ }
public cParent(int a, int b, int c) :this() // Parameterized Constructor
{
this.pubA = a;
this.priA = b;
this.proA = c;
}
}
class cChild : cParent
{
public int pubB;
public cChild()
{ }
public cChild(int a, int b, int c,int d)
: base(a, b, c)
{
this.pubA = a;
this.proA = b;
//this.priA = c; private A connot accesble here because of its access level
this.pubB = d;
}
public void Foo()
{
cParent p = new cParent();
cChild c = new cChild();
proA = 10;
c.proA = 10;
//p.proA = 10; NotAllowed because it is accessble only through child
}
}
class Program
{
static void Main(string[] args)
{
cChild b = new cChild(1, 2, 3, 4);
b.Foo();
}
}
}
No comments:
Post a Comment