override

C++ virtual override functions with same name

Hello there, I have something like that (simplified) class A { public: virtual void Function () = 0; }; class B { public: virtual void Function () = 0; }; class Impl : public A , public B { public: ???? }; How can I implement the Function () for A and the Function() for B ? Visual C++ lets you only define the s...

How to "properly" override a base class method?

Whenever i override a method of a base class, other than my implementation of this method, i seem to have 3 choices. 1) Call base.Method(), and then provide my implementation. 2) Provide my implementation and then call base.Method() 3) Just provide my implementation. Recently while using a library i have realized few bugs that were i...

How to properly extend Java FilterOutputStream class?

I would like to roughly monitor the progress of a file upload. I know that I can override the MultipartEntity and make the writeTo(OutputStream out) method write to a FilterOutputStream class that I created to wrap the default InputStream. For full details on how I did that, see my answer here. However, upon closer inspection this coun...

Unity Register type mapping if missing?

This is similar to This question but the answer doesn't solve my problem. I want to register a default implementation for an interface in code but be able to override that in a config that is read BEFORE the code is run. I want to do something like if (!container.IsImplementationRegistered(typeof(TInterface)) { container.RegisterTy...

overriding inherited getters/setters

I have a class (Wall) that inherits from Sprite. Sprite already has width and height properties. But for wall, I need to do some other additional calculations when the properties change (f.e. make sure the new size won't cause it to overlap any other walls). So, how do I set the width property inherited from the Sprite class from withi...

What's behind the FXCop rule CA1061 "Do not hide base class methods"?

Why is the FxCop rule CA1061 a bad idea? The docs state that this rule should not be suppressed. If I have class like so: public class Set<T> { List<T> m_backingList; public bool Contains(T value) { return m_backingList.Contains(value); } } then I add a specific implementation like this: public class C...

Drupal main theme template file for any node

How can I switch to a different theme template file for any node that I want? I understand how to create sub-themes like node-recipes.tpl.php for a node that has a path of "recipes". But what I want to have control of the entire base template like page.tpl.php. Can I use some preprocess function in template.php for this? Right now I hav...

Having two Page_Load without overriding

I have a class named PageBase inheriting from ASP.NET Page. I want to do something in PageBase's Page_Load. All pages in my application have their logic done on their Page_Load. I'm thinking of a way that Page_Load of both of PageBase and other pages run without having to override Page_Load in pages. Is it possbile? ...

Event Arguments - Should they reflect state snapshots of the moment the event occured or live data?

Hello, It appears that the args object passed into an override of OnPreviewMouseLeftButtonDown describes the current (live) mouse button state, not a snapshot of the state present when the event occurred. Is this proper behavior? Shouldn't event arguments reflect event data at the moment the event occurred (a snapshot) and not be autom...

How to override a method of ruby lib?

When I use ruby 1.8.7 Net::HTTP.post_form(URI.parse(URL), params), I found it has a bug, see : http://stackoverflow.com/questions/3214502/how-to-send-an-array-with-nethttp-post-form My code is a regular ruby script, and I want to override that method(net/http.rb#set_form_data) like this: require 'net/http' require 'uri' module Net ...

How do you control the types of objects you can add to an XElement?

Is there a way to create a class that derives from XElement, but also control the types of objects that can be added to it? For example, say I have this... public class HtmlHead : XElement {} But I can't override the Add() method because it's down at the XContainer level. And even if I was to create a class that derives from XContain...

Creating a namedtuple with a custom hash function

Say I have a namedtuple like this: fooTuple = namedtuple("fooTuple", "item1, item2") And I want the following function to be used for hashing: fooHash(self): return hash(self.item1) * (self.item2) I want this because I want the order of item1 and item2 to be irrelevant (I will do the same for the comparison-operator). I thought...

How to have a single UserControl added to baseform but with different event handlers for same event in the inheriting pages ?

Hi All, This is my application setup : I have a UserControls folder in my application inside which there is my .ascx file which happnes to contain just a simple ASP Button. I have not added any code in the code-behind of the ascx. I have a BaseForm.cs (just a C# class file and NOT an aspx file) which is inheriting from System.Web.UI.P...

Compare two object from the same class with tons of fields

I got two objects from the same class and I need to compare them field by field. The problem is that they have close to hundred fields and it would be helluva work to write that by hand. Do you know any way to do that the easier way? Reflections in Java could be a solution, but yet it seems to me like a hack. And I seek a C# solution af...

before_filter except override not working

Good afternoon all, I've got a controller running a before filter with an except override. It works fine for all the methods in the controller, save one. I've copied the code for the method in question from another part of my app, just making the changes I need to get it working for this particular area. Here is an example of the con...

Can't override a core model in Magento

Hi, I’m trying to override Mage_Catalog_Model_Layer_Filter_Category. In system.log I’m getting a warning: Warning: include(Mycomp_Catalog_Model_Layer_Filter_Category.php): failed to open stream: No such file or directory in /var/www/magento/includes/src/Varien_Autoload.php on line 93 Warning: include(): Failed opening ‘Mycomp_Cat...

drawing a graph in a JPanel in Net Beans

Hi Is there a possible way to override the paintComponent() method in the auto-generated GUI code in NetBeans? I managed to manually draw a graph without using the drag-and-drop components, and I need to make adjustments (e.g. adding radio button group) which I find really time consuming and tedious work. I created a GUI using the Net...

How are explicit interface implementations implemented in IL?

I've been having a look at explicit interface implementations in IL. The method Method in the following class (interface IA has a single Method() on it): public class B : IA object IA.Method() { /* code */ } } is compiled to the following IL method signature: .method private hidebysig newslot virtual final instance ob...

Menu button not working

i want to add some options when a user presses the menu button, i have tried the following but nothing seems to happen when i run the app and press the menu button: the menu xml file <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"&gt; <item android:id="@+id/Map_vi...

override operator with qtscript

I want do a math editor using qtscript. It will support array calculating in script. Such as array1 + array2 = array3.({1,2,3}+{3,4,5} = {4,6,8}); Maybe I need override operator+, I consult the example of QByteArray, and I override operator+,but when I execute in Script,it can't be invoke,anyone coule give me some suggestions? bytearr...