inheritance

Java: Always override equals?

When writing one's own classes, is it always necessary to override equals(Object o)? If I don't, will it automatically check that all the fields are the same? Or does it just check if the two variables point to the same object? ...

C++: Polymorphic class template

Consider a class Calendar that stores a bunch of Date objects. The calendar is designed to hold a collection of any type of objects that inherit from Date. I thought the best way to do it is to have a class template such as template<typename D> class Calendar{ ... } But it struck me that D can now in fact be any class. My questio...

template which enforces interface

Is it possible to create a template accepting types which implement certain interface? For example, I want to say to template user: you can store anything in my container as long as it implements Init() and Destroy() methods. Thanks ...

Custom Wpf Lookless contol...Dynamically Decide Control type

Hi, How to decide the type of a custom lookless control on run time.I have to decide the controls type(ie,whether textbox or combo) on runtime(actually when some Dependency property is bound).How can i do it? Can i define where to inherit from on run time..? ...

Should I avoid message inheritance in WCF?

Generally, I try and avoid using inheritance in WCF contracts, preferring composition. But in the following situation... I have a service operation that can result in one of two things: ResultA and ResultB. There is a boolean/enum in the response message to report this outcome. There are a number of other properties in the response ...

Honouring of AttributeUsage on derived attribute types

Given the following, I would not expect the compiler to allow multiple attributes that are derived from the base attribute, given that is set to AllowMultiple=false. In fact it compiles without a problem - what am I missing here? using System; [AttributeUsage(AttributeTargets.Property,AllowMultiple=false,Inherited=true)] abstract clas...

Inheritance / Architecture

Hi all, Looking for some guidance on how to structure/architect an app and I'm having some difficulties. Please feel free to NOT limit answers to tech details, as I'm not sure I'm doing things the most efficient way. I'm giving examples in VB.NET, but please feel free to use c#, as that's our official target language. I just know vb be...

Is it possible to have 2 Base class's which already inherit from something inherit or know of a third common class?

I have 2 class's Class 1. public class BaseContentPage : System.Web.UI.Page { } Class 2. public class BaseUserControl : System.Web.UI.UserControl { } And now i want them to be aware of this class. public class BaseCommon { public string Variable1 { get; set; } public string Variable2 { get; set; } public string Variable...

Subclassing Python tuple with multiple __init__ arguments

The following code works: class Foo(tuple): def __init__(self, b): super(Foo, self).__init__(tuple(b)) if __name__ == '__main__': print Foo([3, 4]) $ python play.py play.py:4: DeprecationWarning: object.__init__() takes no parameters super(Foo, self).__init__(tuple(b)) (3, 4) But not the following: class Foo(tup...

How can I make the code-behind of UserControls inherit a base class?

I've got a page manager that keeps a collection of pages (usercontrols), sends itself to each page which can thus call its SwitchPage method at anytime enabling me to put in links from one page to another. This works well and allows me to have a quick menu etc. public partial class PageManager : UserControl { private Dictionary<stri...

Objective-C: instance variables out of scope in debugger

I have a superclass and a subclass, both of which define instance variables. Rough outline of superclass: /* GenericClass.h */ @interface GenericClass : NSObject { /* some variables */ } @end /* GenericClass.m */ @implementation GenericClass /* ... */ @end Outline of subclass: /* SpecificClass.h */ #import "GenericClass.h" ...

Accessing a method from a templated derived class without using virtual functions in c++?

How do I get around this? I clearly cannot make the value() method virtual as I won't know what type it is beforehand, and may not know this when accessing the method from b: class Base { public: Base() { } virtual ~Base() { } private: int m_anotherVariable; }; template <typename T> class Derived : public Base { public: ...

Why is my Polymorphic Parent class calling the Subclass Method from within itself?

Heres the code I've made up so far. Its fully functional and the only gripe I have with it is that my output for Weekly and Annual pay is always weekly...I'm at a loss as to how to get this from within either toString method. public class PolyEmployees { public static void main(String[] args) { Employee [] myEmployees = { ...

Serialization of a derived class that hides a base property

I have a class like this MyClass : BaseClass string new FirstName When I try to serialize this class I get the following error message Member SQLClientAdapter.Columns of type hides base class member Adapter.Columns of type ...Use XmlElementAttribute or XmlAttributeAttribute to specify a new name. The recomendation did not work. ...

Inheritance and templates in C++ - why are methods invisible?

When a template publicly inherits from another template, aren't the base public methods supposed to be accessible? template <int a> class Test { public: Test() {} int MyMethod1() { return a; } }; template <int b> class Another : public Test<b> { public: Another() {} void MyMethod2() { MyMethod1(); } }; int ...

How to do Inheritance Modeling in Relational Databases ?

Hi, My question is regarding Inheritance modeling in Relational Database Systems. I have canonical data model and in that I have some fields related to pricing of product inheriting certain attributes from product table and I want to model this inheritance in MySQL relational database and so, "How can we do Inheritance Modeling in Re...

C++ Parent class method call

I'm creating a new class that inherits queue from the STL library. The only addition to the class is a vector. This vector will have the same size of the queue and it will store some integer values that will correspond to each objects in the queue. Now, I want to override pop() and push(), but I simply want to add more functionality to ...

C# inheritance design-pattern question

Hi, I am storing data with different formats and lengths. I have a class hierarchy to represent this: abstract class BaseDataFormat{ abstract void InitalizeFromBytes(byte [] ); } class DataFormat1 : BaseDataFormat{...} // data stored in 3 bytes class DataFormat2 : BaseDataFormat{...} /// data stored in 4 bytes When I am readin...

C++ inheritence for on-stack objects

I have a base class, Token. It has no implementation and as such acts as a marker interface. This is the type that will be used by callers. { Token t = startJob(jobId); // ... (tasks) // t falls out of scope, destructors are called } I have a derived class, LockToken. It wraps around a mutex and insures the lock is acquire...

Is it possible to inherit XAML?

I have usercontrols which inherit a base class which looks like this: BasePage.cs: using System.Windows.Controls; namespace TestPageManager23434 { public class BasePage : UserControl { public string ButtonPreviousText { get; set; } public string ButtonNextText { get; set; } protected PageManager pageMa...