inheritance

how to simulate the inheritance of a record?

I'd like to inherit records, since this is not possible the best solution is to create classes with public fields and use inheritance against them? ...

Understanding Protocol Inheritance in Objective-C

I'll appreciate if anyone can explain the logic behind protocol inheritance. e.g. what does the following mean (UITableView.h): @protocol UITableViewDelegate<NSObject, UIScrollViewDelegate> The following class implementation doesn't work. I have a class View1 (which inherits UIView), with an associated protocol. I have another class,...

Selecting a flavor of classes to implement a function at run-time?

hello, I want to send data and a capability description to a remote site. Upon receiving the data at the remote site, I want to look at the description and create an object (via a factory method ) doing exactly what I want when I invoke exec on it. Examples: 1) send [3, (add 5) ] => receive(obj); obj->exec() -> 8 2) send [3, (add -...

Can you change from a base class to a joined subclass type in nhibernate?

I have document scanning system where several types of documents are scanned. Initially, the document has no information when its scanned, then they get classified and additional information is entered for them in a second step later. So, I have a base class called Document, and subclasses for each type with their respective metadata lik...

How to masquerade child classes in parent class with autoloading (php)

I have a base class that is inherited by about ten subclasses. Most of these subclasses have very similar behavior, but I want to define specialized methods only for three of them. Is it possible to masquerade the existence of these classes, by autoloading the parent class every time an object of the child class is instantiated? This wa...

In Ruby on Rails, what is a good way to get subclass's name in a base controller class?

If both ProductsController and CategoriesController both inherit from GenericController, what is a good way to get the string products in the base class when the URL is pointing to the Products controller? (in this case, the base class's index action is doing things that would need to use the string products to query the database) self...

C++ template inheritance issue with base types

I have the following code and it fails to compile template < typename T > class Base { public: typedef T * TPtr; void func() { } }; template < typename T > class Derived : public Base< T > { public: using Base< T >::TPtr; using Base< T >::func; TPtr ptr; }; int main( int c, char *v[] ) { Derived< int...

VBA, performance, object hierarchy, type structure

I have a some type hierarchy: type A, type B contains field of type A array, type C contains field of type B... (added: I mean type structure, not classes!) I can't use classes by performance reason: type objects copying and creating more fast than the same for classes. But now I need substitute lowest type and than use both types, ol...

Getting the 'parent' or 'host' class of a data member without sacrificing memory

Suppose I have a class MyClass to which I want to add certain 'observer' behavior. Then I could define the class like this: class MyClass : public IObserver { ... }; Now suppose this this 'observer' functionality is not directly related to the class, but to data members stored in the class. E.g. a data member points to another class...

Enforce FK Constraints when JPA inserts inherited objects

I have a multilevel inheritance model in JPA that is using the joined strategy @Entity @Table(name="PARTY") @Inheritance(strategy=InheritanceType.JOINED) @DiscriminatorColumn(name="PARTY_TYPE",discriminatorType=DiscriminatorType.STRING) public class Party implements Serializable{ ... } @Entity @Table(name="PARTY_ORG") @DiscriminatorVal...

Why don't I get a compiler warning when I implement an interface that a base class also implements?

In the following code, I'm implementing an interface, and then deriving from that class and implementing the same interface. When I dispose an instance of the derived class, it only calls the derived implementation. Why wouldn't the C# compiler warn about this? It seems dangerous for a couple reasons. I could implement an interface that...

How can I assign a child class to a base class?

I know there are solved questions related to this issue, but I still can't figure out how to resolve my problem. I have something like this: class Base { static Base* createBase() { Base *b = new Base(); ... //does a lot of weird things return b; } } class Child : public Base { static Child* createChild()...

Objective-C Late Static Binding

I'm teaching myself Objective-C as a guilty pleasure, if you would. I have a self-proclaimed strong grasp of the Java language, so it's not a terribly difficult transition – it sure is fun though. But alas, my question! I'm attempting to reproduce something that exists in PHP: Late Static Binding. In PHP, I can decorate a method call w...

What is the difference between same-named inherited function and overridden virtual function ?

#include <iostream> using namespace std; class base { public: void f() {cout << "base" << endl;} virtual void v() {cout << "base (virtual)" << endl;} }; class deriv : public base { public: void f() {cout << "deriv" << endl;} void v() {cout << "deriv (overridden)" << endl;} }; int main() ...

Inheritance in generic types

Can anyone help me in using Where for generic types? I was trying to create a function which does ST with a number of type double or int, so I said it should be generic function. But when I try to assign a value to variables of that generic type, I can't because it's not a numerical type. Also, I can't use Where to inherit generic type f...

Hibernate inheritance and HQL

Hello Hibernate daemons, I have inheritance in Hibernate for where Connection is my parent entity, and MobilePhoneConnection is extended entity. I used one table per subclass strategy for inheritance mapping. This is my file: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3...

Problem with nested StackPanels and DataContext inheritance in Silverlight 4

I have a problem with nested StackPanels. If I define StackPanels like in the code below, button binds to command (MVVM and command pattern) but doesn't react on button click (command function is not called). When I put stackPanel4 on second position (below stackPanel3) everything works ok. When I move stackPanel4 on the last position (I...

Inherit from a class in a wcf service

Hello I want to inherit from a class which is located in a WCF Service. The Inheritance works fine (I see the properties of the base class in my child class), my problem occurs when I try to call a method from the service and pass the childtype as a parameter and not the basetype. Base class in WCF Service (Pet): [ServiceContract] pub...

Is Inheritance the correct approach.

We have a base TCP Server class which provides Server functionallity. Now we want to provided secure TCP Server functionality as well. There were two approaches we were debating on. Pass a value to TCP server constructor, indication whether it should act as TCPServer or TCP secure server. Create a TCPSecure class inheriting from TCP Se...

JavaScript Inheritance

If I have an object that I want to "inherit" methods from a "super object" to ensure consitency. They will be intermingling variables. REVISED ParentObj = function() { var self = this; this.interval = null this.name = ""; this.timeout = 1000; this.stop = function() { clearInterval(self.interval); }; ...