Sample: class clsA { int a,b; public clsA(int nA,int nB) { a=nA; b=nB; } public int Add() { return a+b; } private int AddX() { return a+b; } } class clsB:clsA { public clsB(int nA,int nB):base(nA,nB) { } public int AddB() { //return this.AddX();//Can't be used return this.Add(); } }
to Knight94() 有点不懂... clsB继承了clsA,clsA的方法clsB中不是都可以引用吗? public int AddB() { //return this.AddX();//Can't be used return this.Add(); } 不懂为什么AddX方法不能够用...?
base()父类的构造 方法。(当然有不同参数的重载。)
class clsA
{
int a,b;
public clsA(int nA,int nB)
{
a=nA;
b=nB;
} public int Add()
{
return a+b;
} private int AddX()
{
return a+b;
}
} class clsB:clsA
{
public clsB(int nA,int nB):base(nA,nB)
{
} public int AddB()
{
//return this.AddX();//Can't be used
return this.Add();
}
}
有点不懂...
clsB继承了clsA,clsA的方法clsB中不是都可以引用吗?
public int AddB()
{
//return this.AddX();//Can't be used
return this.Add();
}
不懂为什么AddX方法不能够用...?