views:

50

answers:

1

I'm having an issue with inheritance between 2 classes and a single normal class. Here is an example of what I have:

Abstract ClassA function get_name();

Abstract ClassB extends ClassA

ClassC extends ClassB

Now, when I create an object of ClassC, I can't access the get_name() function. I'm not sure what I'm doing wrong here. Any help would be very much appreciated!

+3  A: 

get_name() must be a protected or public function for ClassC or ClassB to access it.

If you don't have one of these parameters declared in ClassA, only ClassA will be able to use get_name();

public class ClassA
{
    protected CharSequence get_name()
    {
         return "ClassA";
    }
}

Think about it, it doesn't make much sense to have an abstract private function, since no other object will ever be able to implement it or access it.

CodeFusionMobile
Without a word in front it is package not private
bwawok