Все вопросы: [overriding]

154 вопросов

похожие теги:
42
голосов
3ответов
12092 просмотров

Why can't you reduce the visibility of a method in a Java subclass?

Why does the compiler give an error message when you reduce the visibility of a method while overriding it in the subclass?

3
голосов
2ответов
313 просмотров

How do I override a property in a non-inheritable class?

In the MSDN documentation, System.Reflection.Assembly has a property called CodeBase which is defined as overridable. Public Overridable ReadOnly Property CodeBase As String However, if I try to create a new class that inherits System.Reflection.Assembly, I get an error message that tells me i...

1
голосов
2ответов
908 просмотров

Make Hashtable immutable

How do I make a derived class from Hashtable, objects of which can be added, but cannot be removed or replaced? What do I have to override and particularly how do I override the [] operator?

1
голосов
2ответов
685 просмотров

Polymorphism (not) broken with visitor pattern in C# (and new instead of override)

I have the following code: class Visitor { internal virtual void Visit(Node n) { } } class VisitorSpecial : Visitor { internal new void Visit(Node n) { } } class Base { internal virtual void Accept(Visitor v) { } internal virtual void Accept(VisitorSpecial v) { } } class No...

5
голосов
3ответов
3680 просмотров

Inherited method needs one more parameter

I have a parent class with several children. One of the children, has one overridden method that, for its particular internal usage, needs one more parameter. I don't want to change the method's signature because the overridden method in the other children does not need this parameter, also, I do...

2
голосов
3ответов
7845 просмотров

VB.NET overload default functionality when user clicks the X (Close Program)

How do I go about overriding the default functionality when a user clicks the X in a VB.NET form-based application? I am currently handling the MyBase.Closing event... but since it's a DirectX app, I need to do some cleanup before allowing the form the close.

1
голосов
1ответов
572 просмотров

Extend HTML_BBCodeParser_Filter

I'm trying to add extra tags to the PEAR package BBCodeParser http://pear.php.net/package/HTML_BBCodeParser/docs/latest/li_HTML_BBCodeParser.html, to do this, I believe I need to place Object.php in \php5.3.0\PEAR\pear\HTML\BBCodeParser\Filter and call addFilter. Object.php <?php /* New fi...

5
голосов
6ответов
2826 просмотров

method overriding in Java

How is method overriding implemented in Java? In C++ we have the concept of vtable.. how is this implemented internally in Java?

38
голосов
3ответов
11297 просмотров

What is this type of method overriding called in Java?

I'm relatively new to Java and I'm using a new API. I came across this method override and I'm not sure what this is called: public void exampleMethod() { Button loginButton = new Button("login"){ public void onSubmit(){ //submit code here } }; } From what I und...

2
голосов
1ответов
1910 просмотров

Why does XMLSerializer take DefaultValue Attribute of base class to serialize

using System.ComponentModel; using System.IO; using System.Xml.Serialization; namespace SerializerTest { static class Program { static void Main() { using (TextWriter textWriter = new StreamWriter("data.xml")) { Data data = new Data(); new ...

7
голосов
5ответов
13907 просмотров

C#: Overriding OnPaint on ProgressBar not working?

Was thinking it should be pretty easy to create a ProgressBar that drew some text upon itself. However, I am not quite sure what is happening here... I added the following two overrides: protected override void OnPaintBackground(PaintEventArgs pevent) { base.OnPaintBackground(pe...

17
голосов
1ответов
8813 просмотров

java override during object creation

in the following java code a JButton is created but at the same time one of its methods gets overridden. Qestion: is there a name for overriding in this way while creating the object? the code: JButton myButton; myButton = new JButton ("ok"){ @Override public void setText...

3
голосов
2ответов
164 просмотров

Using all overloads of the base class

When a subclass overrides a baseclass's method, all of the baseclass's overloads are not available from the subclass. In order to use them there should be added a using BaseClass::Method; line in the subclass. Is there a quick way to inheirt the baseclass's overloads for ALL of the overridden me...

0
голосов
1ответов
249 просмотров

How do I prevent security overrides in my WCF service config file?

I have to create a WCF service which returns sensitive information to the client. I need to ensure that the security of the service cannot be compromised easily. I'll use WCF's built in security mechanisms to protect the data on the wire by using a wsHttpBinding with certificate security. Howeve...

4
голосов
11ответов
305 просмотров

Subclasses causing unexpected behavior in superclasses — OO design question

Although I'm coding in ObjC, This question is intentionally language-agnostic - it should apply to most OO languages Let's say I have an "Collection" class, and I want to create a "FilteredCollection" that inherits from "Collection". Filters will be set up at object-creation time, and from them...

8
голосов
1ответов
2747 просмотров

C++ override/overload problem

I'm facing a problem in C++ : #include <iostream> class A { protected: void some_func(const unsigned int& param1) { std::cout << "A::some_func(" << param1 << ")" << std::endl; } public: virtual ~A() {} virtual void some_func(const unsigned int&amp...

3
голосов
2ответов
1621 просмотров

Isolating Ruby methods from overriding in subclasses? (like Java's private methods)

In Ruby, I'd like to acheive something like this Java sample: class A { private void f() { System.out.println("Hello world"); } public void g() { f(); } } class B extends A { public void f() { throw new RuntimeException("bad guy");} } public class Try { public static vo...

4
голосов
5ответов
779 просмотров

What's going on with overriding and overloading here in C++?

This doesn't work: class Foo { public: virtual int A(int); virtual int A(int,int); }; class Bar : public Foo { public: virtual int A(int); }; Bar b; int main() { b.A(0,0); } It seems that by overriding Foo::A(int) with Bar::A(int) I have somehow hidden Foo::A(int,int). If I ad...

10
голосов
4ответов
8675 просмотров

Overriding a private method with Reflection

Is it possible to override a private method by using Reflection in .NET 3.5?

14
голосов
8ответов
14528 просмотров

C++ Overridden method not getting called

Shape.h namespace Graphics { class Shape { public: virtual void Render(Point point) {}; }; } Rect.h namespace Graphics { class Rect : public Shape { public: Rect(float x, float y); Rect(); void setSize(float x, float y); virtual void...

2
голосов
1ответов
2685 просмотров

How do you override a TableAdapter method on a Table in a DataSet?

I currently have a single DataSet declared which contains 3 tables. For sake of this example we will call them User, Question and Answer. On each of these I have a TableAdapter with the various methods required, ie. GetData(), Update(), Delete() etc. On the Answer Table I would like to override...

0
голосов
1ответов
1117 просмотров

MasterPage and ViewState (VB.Net)

Ok So i have written methods to override the LoadPageStateFromPersistenceMedium and SavePageStateToPersistenceMedium methods. now the problem is that i am using a masterpage, so how do i maintain using my masterpage and still inherit from System.Web.UI.Page? Please bear in mind that the .vb Code...

21
голосов
4ответов
3290 просмотров

In C++, is a function automatically virtual if it overrides a virtual function?

I would expect that if foo is declared in class D, but not marked virtual, then the following code would call the implementation of foo in D (regardless of the dynamic type of d). D& d = ...; d.foo(); However, in the following program, that is not the case. Can anyone explain this? Is a me...

201
голосов
14ответов
81864 просмотров

Difference between new and override

Wondering what the difference is between the following: Case 1: Base Class public void DoIt(); Case 1: Inherited class public new void DoIt(); Case 2: Base Class public virtual void DoIt(); Case 2: Inherited class public override void DoIt(); Both case 1 and 2 appear to have the sa...

18
голосов
1ответов
6276 просмотров

Scala overriding a non-abstract def with a var

In Scala I can do this: trait SomeTrait { protected def foo: String } class Wibble extends SomeTrait { protected var foo = "Hello" } But I cannot do the same thing where I provide a default definition for foo trait SomeTrait { protected def foo: String = "World" } class Wibble extends...

0
голосов
1ответов
167 просмотров

Strange Property Override in DataGridViewTextBoxCell

If you look at the DataGridViewTextBoxCell property, ValueType, in reflector, you can see it overrides a property from DataGridViewCell. The strange thing is, is that the overriden property is readonly, but the property in the parent class is read and write. I can only presume that the property...

6
голосов
5ответов
3382 просмотров

Overriding std functions

I'd like to override the behavior of an std function, say std::time. Is it possible to call std::time and have it routed through my custom function?

0
голосов
5ответов
1285 просмотров

Java override explanation

Here is my code class Glyph { void draw() { System.out.println("Glyph.draw()"); } Glyph(int i) { System.out.println("Glyph() before draw()"); draw(); System.out.println("Glyph() after draw()"); } } class RoundGlyph extends Glyph { private int radius = 1; RoundGl...

0
голосов
2ответов
1663 просмотров

Override java.awt.Button

I am trying to override default java Button behavior and trying to add additional label to a button. I am new to java GUI and thought that overriding paint method will solve my problem, but when I do that and draw additional label in Button paint method it looks fine, but my label disappears if I...

13
голосов
3ответов
4083 просмотров

Confusing "override a private method"

I have two question on this code public class Override { private void f() { System.out.println("private f()"); } public static void main(String[] args) { Override po = new Derived(); po.f(); } } class Derived extends Override { public void f() { ...