inheritance

Anyway to override a bool property with a Nullable<bool> property

I'm almost sure the answer is simply no, you can't do that. So I'm working on options for my app. I've got a decent setup so I have the global options and the local options since you can have different options selected on different tabs. For the global options I want to represent when an option isn't consistent across all the tabs by r...

Partial classes/partial methods vs base/inherited classes

Hello folks, a question about class design. Currently I have the following structure: abstract Base Repository Class Default Repository implementation class (implements some abstract methods, where logic is common thru all of the Specific classes but leaves other empty) Specific Repository implementation Class (implements what is left...

Issues with Partial Class Function Overrides in C++

Is there any issue with partially overriding a set of virtual functions defined by a base class? My compiler provides the following warning: overloaded virtual function "MyBaseClass::setValue" is only partially overridden in class "MyDerivedClass". The classes look like this: class MyBaseClass { public: virtual void setValue(int...

Using delegates to avoid subclassing

I would like to have your opinion as to the pros and cons of using delegates instead of virtual functions aud subclassing? ...

C++ Trouble with operator code inheritage: am I require to copy same code for all derived classes?

I'd like to write a group of class D_I (aka I=1,2,... just I mean '_I' to be class proper name, not integer) which handle some (boolean, for example) operations F with same meaning for all classes. But also I want to operate with "sums" of object of such classes, different classes of the group might be "added" together. Mentioned operati...

compile error when I use C++ inheritance

Hi, I am new to this website and I am trying a simple inheritance example in C++. I checked my code lots of times and I really see nothing wrong with it, however the compilers gives me errors: my code: #ifndef READWORDS_H #define READWORDS_H using namespace std; #include "ReadWords.h" /** * ReadPunctWords inherits ReadWords, so MUST...

In C#, can a class inherit from another class and an interface?

I want to know if a class can inherit from a class and and interface. The example code below doesn't work but I think it conveys what I want to do. Does anyone have any recommendations??? The reason that I want to do this is because at my company we make USB, serial, Ethernet, etc device. I am trying to develop a generic component/inte...

C++ specialized template inherit from non-specialized version

I was trying to solve a problem, but found a different solution. however out of curiosity like to know if the following is possible: template< class > struct S; template< > struct S< Foo > : struct< Foo > {}; I would like to be able to inherit nonspecialized struct from specialized struct.the example above does not work because the in...

Issue adding an inherited object in Entity Framework.

I am working on a small project using Entity Framework. I have a Group entity and a MissionTrip:Group entity (and also a SmallGroup:Group entity but that shouldn't be necessary information). I am using Table-Per-type inheritance set up analogously to the inheritance in this blog post by Muhammed Mosa. I can't save a MissionTrip to the G...

Is there a base object for a c# enum?

I know that you can't use inheritance with enums, so in my base class I want to define that the classes that implement it must return an enum of some type for a property. Ideally, this would be like: public abstract BaseEnum MyEnum { get; set; } Then all the implementers would have to return some form of enum. But obviously BaseEnum ...

Problem with form inheritance c#

Well first of all sorry for the English. I have the following problem: I have a base form with a panel docked to the bottom and inside the panel some buttons. The forms inheriting this base form can modify the visibility of the base form buttons by properties like "ButtonCloseVisiblity" that appears in the child form properties. The prob...

Diamond Problem

Wikipedia on the diamond problem: "... the diamond problem is an ambiguity that arises when two classes B and C inherit from A, and class D inherits from both B and C. If a method in D calls a method defined in A (and does not override the method), and B and C have overridden that method differently, then from which class does it inheri...

python parent class 'wrapping' child-class methods

Hello all, I have the following situation in my python code: class Parent(object): def run(self): print "preparing for run" self.runImpl() print "run done" class Child(Parent): def runImpl(self): print "child running" However, I have several such 'decorators', doing different setup/teardown ste...

Easiest way to make C# not instantiate a class unless inherit?

What is the easiest way to make C# not instantiate a class unless inherit? Sounds weird but i dont want to explain the why. I have a base class and two class that inherit it. I want to use the derived class only and not the base. The derive class does not have any extra functions. Whats the easiest way to NOT allow me to write new BaseC...

Overriding equals() & hashCode() in sub classes ... considering super fields

Is there a specific rule on how Overriding equals() & hashCode() in sub classes considering super fields ?? knowing that there is many parameters : super fields are private/public , with/without getter ... For instance, Netbeans generated equals() & hashCode() will not consider the super fields ... and new HomoSapiens("M", "80", "1...

Why does cocoa use delegates rather than inheritance?

Why does cocoa use delegates rather than inheritance? ...

Force an inheritor to initialise a field of the base from its CTOR (C#)

I'm trying to enforce an inheritor of an abstract class to initialize one of the fields in the base. I can't do this via a constructor in the base because the type of the field requires a reference back to the object creating it. (I suppose I could provide a parameterless ctor for the field type. But I feel that would just be shifting t...

C++: how to prevent destructing of objects constructed in argument?

I have a questing around such staff. There is a class A which has a object of type class B as it's member. Since I'd like B to be a base class of group of other classes I need to use pointer or reference to the object, not it's copy, to use virtual methods of B inside A properly. But when I write such code class B {public: B(in...

Defining is_a predicate in prolog?

Hello, I'm trying to define the inheritance-check predicate is_a/2 in Prolog, but so far all my trials failed. The is_a(X, Y) predicate should return true whenever Y is a superclass of X. For example: object(bare). object(mammal). object(animal). object(bird). is_a(bare, mammal). is_a(mammal, animal). is_a(bird, animal). is_a(X, Y):- ...

virtual function question...

#include "stdafx.h" #include <iostream> #include <vector> #include <string> class Helper { public: Helper() { init(); } virtual void print() { int nSize = m_vItems.size(); std::cout << "Size : " << nSize << std::endl; std::cout << "Items: " << std::endl; for(int i=0; i<nSize; i++) { s...