overriding

Generic overloading tells me this is the same function. Not agree.

base class: Class List(Of T) Function Contains(ByVal value As T) As Boolean derived class: Class Bar : List(Of Exception) ' Exception type as example ' Function Contains(Of U)(ByVal value As U) As Boolean compiler tells me that that two are the same, so I need to declare Overloads/new this second function. But I want use U...

C# Hiding, overriding and calling function from base class.

I'm learning C# and I encountered the following problem. I have two classes: base and derived: class MyBase { public void MyMethod() { Console.WriteLine("MyBase::MyMethod()"); } } class MyDerived: MyBase { public void MyMethod() { Console.WriteLine("MyDerived::MyMethod()"); } } For now, withou...

Deriving a class from an abstract class (C++)

I have an abstract class with a pure virtual function f() and i want to create a class inherited from that class, and also override function f(). I seperated the header file and the cpp file. I declared the function f(int) in the header file and the definition is in the cpp file. However, the compiler says the derived class is still abst...

In C#, can I hide/modify accessors in subclasses?

I'm not even sure what this principle is called or how to search for it, so I sincerely apologize if it has been brought up before, but the best way to do it is with an example. class Properties { public string Name { get; set; } } class MyClass { class SubProperties: Properties { public override Name { ...

Overriding Equals method in Structs

I've looked for overriding guidelines for structs, but all I can find is for classes. At first I thought I wouldn't have to check to see if the passed object was null, as structs are value types and can't be null. But now that I come to think of it, as equals signature is public bool Equals(object obj) it seems there is nothing preve...

How to override nested C++ objects methods?

Hi all, I didn't figure out a better title for the question. Let me explain it better now: The project I am working on is going to connect to a remote server, encrypt the session and send/receive data packets. I'd like to make it modular enough, so I thought it'd be nice to use 3 distinct classes. These would be: 1) A socket wrapper cl...

Strange GWT serialization exception when overiding method of serialized object

Hi there! I have a GWT serializable class, lets call it Foo. Foo implements IsSerializable, has primitive and serializable members as well as other transient members and a no-arg constructor. class Foo implements IsSerializable { // transient members // primitive members public Foo() {} public void bar() {} } Also a Service whi...

Access specifier while overriding methods

Assume you have a class that defines virtual methods with the access specifier public. Can you change the access specifier on your overriden methods? I am assuming no. Looking for an explanation. ...

Partial overriding in Java (or dynamic overriding while overloading)

If I have a parent-child that defines some method .foo() like this: class Parent { public void foo(Parent arg) { System.out.println("foo in Function"); } } class Child extends Parent { public void foo(Child arg) { System.out.println("foo in ChildFunction"); } } When I called them like this: Child f = new Child();...

QWidget keyPressEvent override

Hi there, I'm trying for half an eternity now overriding QWidgets keyPressEvent function in QT but it just won't work. I've to say i am new to CPP, but I know ObjC and standard C. My problem looks like this: class QSGameBoard : public QWidget { Q_OBJECT public: QSGameBoard(QWidget *p, int w, int h, QGraphicsScene *s); signals: v...

Overriding Built-in Classes (Python)

How can I view and override the full definition for built in classes? I have seen the library docs but am looking for something more. For e.g. is it possible to override the Array Class such that the base index starts from 1 instead of 0, or to override .sort() of list to a sorting algorithm of my own liking? ...

Override An Existing Property as a Child form of its return type

I apologize if that title is confusing. This question may be a result of lack of coffee and/or sleep, but my mind is not working correctly right now. Anyways, I have an inheritance tree like so (I know the architecture isn't ideal): BaseClass GeneralForm : Inherits BaseClass SpecificForm : Inherits GeneralForm And an object like so...

Overriding Django Admin's main page? - Django

Hi folks, I'm trying to add features to Django 1.2 admin's main page. I've been playing with index.html, but features added to this page affect all app pages. Any ideas on what template I'm supposed to use? Thanks loads!! ...

Few Basic Questions in Overriding

I have few problems with my basic and would be thankful if someone can clear this. 1: What does it mean when I say base *b = new derived; Why would one go for this? We very well separately can create objects for class base and class derived and then call the functions accordingly. I know that this base *b = new deriv...

Best practices regarding equals: to overload or not to overload?

Consider the following snippet: import java.util.*; public class EqualsOverload { public static void main(String[] args) { class Thing { final int x; Thing(int x) { this.x = x; } public int hashCode() { return x; } public boolean equals(Thing other) { return this.x ==...

C++ inheritance and method overloading

Why C++ compiler gives this error? Why i can access lol() from B, but can not access rofl() [without parameters]. Where is the catch? class A { public: void lol(void) {} void rofl(void) { return rofl(0);} virtual void rofl(int x) {} }; class B : public A { public: virtual void rofl(int x) {} }; int _tmain(int argc, _TCHAR*...

Obj-c method override/polymorphism problem

Ok, so I'm using Objective-C. Now, say I have: TopClass : NSObject - (int) getVal {return 1;} MidClass : TopClass - (int) getVal {return 2;} BotClass : MidClass - (int) getVal {return 3;} I then put objects of each type into an NSMutableArray and take one out. What I want to do is run the getVal func on the appropriate object type, ...

Static and overriding in Java

public class B { static int i =1; public static int multiply(int a,int b) { return i; } public int multiply1(int a,int b) { return i; } public static void main(String args[]) { B b = new A(); System.out.println(b.multiply(5,2)); System.out.println(b.multipl...

Overriding setters not being called in Objective-C

I'm debugging a sample tutorial snippet and am confused about the overriding of setters. I declare and override as shown here: // // PolygonShape.h // @interface PolygonShape : NSObject { int numberOfSides; } @property int numberOfSides; // // PolygonShape.m // @synthesize numberOfSides; // custom setter. - (void) setnumber...

Override explicitly implemented interface method in derived class

I want to explicitly implement an interface method on a base class. Beyond this, I wanted to make this method virtual so I could override it on a derived class, but explicitly implemented methods do not allow this. I have tried making a protected virtual method in the base, calling this from the interface method, and then overriding th...