locked
Private MustOverrride in vb.net - why not? RRS feed

  • Question

  • User1146730029 posted

    I have a parent class called Feature that cannot be instantiated.

    I then have various child classes that inherit the Feature class.

    I want to make sure that all the child classes implement a function, but I dont want this function exposed (i.e. I dont want it public).

    Why cant I set a Private MustOverride function?

    What would be the best way to do this?

    Tuesday, January 18, 2011 7:16 AM

Answers

  • User1682618242 posted
    Public MustInherit Class Feature
    {
         Protected MustOverride FeatureFunction() as Int
    }
    


    Or maybe I understood wrong...

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 26, 2011 4:31 AM
  • User712082397 posted

    Why cant I set a Private MustOverride function?

     

    As per OO concepts, if you make anything "Private" then you cannot inherit it. Hence you cannot have a Private function defined in your Feature class that you want to be implemented by child classes.

    Your best bet is to use "Protected". This will enable your function to be available for inheritance but would not expose this function to the entire world.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 28, 2011 2:50 PM

All replies

  • User1682618242 posted
    Public MustInherit Class Feature
    {
         Protected MustOverride FeatureFunction() as Int
    }
    


    Or maybe I understood wrong...

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 26, 2011 4:31 AM
  • User712082397 posted

    Why cant I set a Private MustOverride function?

     

    As per OO concepts, if you make anything "Private" then you cannot inherit it. Hence you cannot have a Private function defined in your Feature class that you want to be implemented by child classes.

    Your best bet is to use "Protected". This will enable your function to be available for inheritance but would not expose this function to the entire world.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 28, 2011 2:50 PM