What OO languages ​​allow you to subtract functions from a class?

In C ++ and most object oriented lanuages, I know when you get class B from an existing class A, you can add new methods, override existing methods and add new data members. If A has some fragments that you do not want in B, you cannot eliminate them. Perhaps most of the time this does not make sense, but there were moments that I would like to make.

Are there any languages ​​that allow you to define a derived class with some of its parent elements?

+3
source share
5 answers

, , , , , .

, IS-A . , ? ? , , , .

, . , UnsupportedOperation, .

+5

( , OO), . . :

q (x) - , x T. q (y) y S, S - T.

, "is a": D B, D B. B, .

, : ( D, A/), OO, ( , /).

+3

, - .

, Windows Forms Property Grid, . Control , Text, , ( Windows Forms) , , , , ..

, - , - , , , , .

// Don't show this property in the Property Grid
[Browsable(false)]

// Don't save this property design-time value to be reloaded at runtime
// (i.e. don't generate a property assignment in the .designer.cs file)
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

// Don't show this property in the editor Intellisense code-completion lists
[EditorBrowsable(EditorBrowsableState.Never)]

public override string Text {
    get { return base.Text; }
    set { base.Text = value; }
}

, , - - . ( , , .)

+1

Aspect Oriented Programming - , . , AspectJ. , , , , , , (, ). - , , .

+1

Well ... if you follow the aspect programming methods and use interfaces, then you should be able to effectively "hide" implementation details that you do not want your users to see, since they will only have access to interface members

0
source

Source: https://habr.com/ru/post/1780471/


All Articles