How to access a 2-level deep base-class member

  • Thread starter Thread starter Ken Durden
  • Start date Start date
K

Ken Durden

Hey,

I'm trying to access a function in my base class's base class. I want
to skip one level in the hierarchy.

class A
{
virtual void foo()
{ Console.WriteLine( "A::foo" ); }
}

class B : A
{
virtual void foo()
{ Console.WriteLine( "B::foo" ); }
}

class C : B
{
virtual void foo()
{
Console.WriteLine( "C::goo" ); }
xxxx.foo(); // should print A::foo
}
}


I've tried:

A.foo();
base.A.foo();
this.A.foo();
base.base.foo();


I know I can do this by putting a function on B which calls A::foo()
such as

class B
{
void A_foo()
{
base.foo();
}
}

But this is exceedingly dumb.

Is what I want to do possible?

-ken
 
Ken,

No, it is not. You will have to use the "exceedingly dumb" method that
you pointed out. =)

When using base versions of methods on a class, derived types only have
access to the class they derived from.

Hope this helps.
 
Back
Top