inheritance

Accessing protected variables from parent class in JRuby

I'm trying to get at the protected variables that are defined in the parent class I have inherited from. Is this possible? I can't find any documentation saying it is. I've seen tickets that have been closed on earlier versions of JRuby. Any help would be great. Edit: To clarify public class Something { protected float somethingel...

c# : Inheritance of the form By procedure

How is Inheritance of the form By procedure ? ...

How to get an object's specific type and cast the object to it in Scala?

For example GeneralType is a class or a trait extended by many more specific types, including, to say, SpecificType. A function takes an argument of type GeneralType, and then whant's no know if the actual argument passed is a SpecificType instance and act accordingly (use its special fields/methods) if it is. How to code this in Sca...

Collections with component references and form inheritance

Some time ago I developed a component that had TCollection descendant property and items from this collection contained referenced to the controls on the form. Everything was ok with this component except for inheritance. I don't know about the latest versions of Delphi, but with older ones when a collection is inherited there were two v...

How can I initialize a const variable of a base class in a derived class' constructor in C++?

I have an abstract C++ class with no constructor. It's supposed to be a base class so other classes can inherit from it. What I am trying to do is to declare a constant variable in the base class and initialize it in each derived class' constructor but nowhere else in each one of those classes. Is it legal in C++? If so, how can I do tha...

How to create class containing property of various types in C#

I'm trying to create a class to represent the value of a column in SQL. Here's the final goal I want to reach: public string GenerateInsertSql() { StringBuilder insertSql = new StringBuilder(); insertSql.Append("INSERT INTO " + SchemaName + "." + TableName + "\n"); insertSql.Append("(\n"); int counter = 0; foreach (ColumnValue...

How to retrieve the constructor's name in JavaScript?

Assume the following program: var C = function() { }; x = new C(); The expression x instanceof C yields True, so x has to know somehow that it was constructed by the function C. Is there way to retrieve the name C directly from x? (In my problem at hand, I have a hierarchy of prototypes implementing possible signals in my application...

When should I call super?

What is the best using of [super ... any method name]. Recently I have found out that In dealloc the [super dealloc] must stand in the same end. Because any variable what didn't use before can be filled by garbage if we set it after [super dealloc] It's a rare thing, but it's possible. After this we will have crash in our app. So what i...

PHP: require_once and inheritance

If I have: <?php require_once("bla.php"); class controller{.....} php> If I then create in a different file class control_A extends controller{...}, do I need to again say require_once("bla.php");, or is it inherited? What if the require_once is done inside the class controller definition? Thanks! JDelage ...

Dynamic Cast working on unrelated types

#include <iostream> using namespace std; class X{ public: virtual void f(){} }; class Y { public: virtual void g() {} }; int main() { X * x = new X(); Y* y = dynamic_cast<Y*>(x); //A // Y* y = static_cast<Y*>(x); //B cout << y << endl; } A compiles whereas B doesn't. I underst...

UserControl Inheritence Base controls not being created!!

Can anyone tell me how to fix issue im having with usercontrol inheritence. create Base usercontrol which contains a label and sets text of it to be "test1" this is set in the designer. Create a user control which inherits from the base user control. now try to display the inherited user control on a web page but noting shows. i.e. t...

Dynamic Inheritance using a factory

I think I know the answer to this but hoping someone has a neat solution. We are currently using two kinds of drop down controls (telerik and .net). I'm hoping to combine these into one control but struggling with a user friendly design. Ideally the control would be created in the design file with a bool property of say "SimpleBox", to...

undefined method `update_attribute' for ActiveRecord::Relation when called on record retrieved through inheritance

I have a polymorphic association relationship happening, and when I retrieve a record through it, such as: hour = my_model.find( keeper_id ).hours.where( "day = ?", day_index ) Then try to call update_attributes on it: hour.update_attribute(:start_time, start_time) I get an error: NoMethodError (undefined method `update_attribute'...

Inherit a Static Variable in Java

I want to have the following setup: abstract class Parent { public static String ACONSTANT; // I'd use abstract here if it was allowed // Other stuff follows } class Child extends Parent { public static String ACONSTANT = "some value"; // etc } Is this possible in java? How? I'd rather not use instance variables/met...

How to mix inheritance strategies with JPA annotations and Hibernate?

According to the Hibernate Reference Documentation it should be possible to mix different inheritance mapping strategies when using Hibernate's XML-Metadata: http://docs.jboss.org/hibernate/stable/core/reference/en/html/inheritance.html#inheritance-mixing-tableperclass-tablepersubclass However, the corresponding section of the Hibernate...

UserControl inside class vs class inside UserControl for Windows Forms

I'm working on a modular project consisting of multiple sensors, each inheriting from an abstract Sensor class. To configure each sensor, I have started to add a user control panel for each sensor (inherits from UserControl), which is loaded at runtime and displayed in a panel by the calling application. But then I realised that to chan...

trigger method in inherited class - windows forms

Hello, this is my scenario, and I want to know if it's possible to accomplish what I intend to do: I have a class library (made in c#) that inside has a class (named SForm) that inherits from System.Windows.Forms.Form. In that class I declare some strings, and methods to set those strings' values. public class SForm : Form { public ...

Visual Studio 2010 designer error

Hi, I'm having a problem with some custom forms I developed. This form worked perfectly with VS2008, but is causing an error with VS2010. Going back to VS2008 is a worst case scenario option for various reasons. Anyway the problem - When I try to view a form of type FormWithError in design mode I get the standard "To prevent possible...

foreach(Derived obj in new List<Base>())

What does the following code do? class Base { } class Derived : Base { } class Test { void Foo(List<Base> list) { foreach (Derived obj in list) { // ... } } } I didn't expect it to even compile, but it does. ...

Base class's function pointer points to child class's member function?

I know it sounds awefully confusing, I have a base template class which has a function pointer, a child class(which is no longer a template class) needs to use that function pointer to point to a child class's member function, and I get all kinds of errors.. Did I violate some universal law of C++? here is the pseudo code: template <cla...