inheritance

PHP Inherited parent method can't access child's private property

First of all: A quite similar problem has been posted and somehow solved already, but is still not answering my specific problem. More about this later. In words: I have a base class which provides some methods to all childs, but doesn't contain any property. My child is inheriting these methods, which should be used to access the child...

Better way of refactoring this ?

I have the following classes: public abstract class BaseClass { private readonly double cachedValue; public BaseClass() { cachedValue = ComputeValue(); } protected abstract double ComputeValue() } public class ClassA : BaseClass { protected override double ComputeValue() { ... } ...

c++ cli inhert from generic(template) interface

hello, I am writing a wrapper for a class written in C++. I must have an template interface class and inherif a wrapper class for a certain type of variable. this is the code template<typename T> public interface class IDataSeriesW { property T default [int] { T get (int Index); void set (int Index ,T val); } }; publi...

Create a SharePoint abstract parent content type

Is it possible to make a content type "abstract" in SharePoint 2010, i.e. users will only able to use the content types that inherit from the parent, and not create items/lists that use the base content type directly? ...

How to downcast a Java object?

Hello, I am trying to understand Java's polymorphism, and I have one question about downcasting an object. Let's say for this example I have two subclasses Dog and Cat that inherit from a superclass Animal From what I understood, the only way to downcast an object is if this Object is already of the good type, like this: Animal a = ne...

Add Jar file to GWT source path?

Hi I have some JAR file, I need to reference it from GWT Source package. How can I accomplish that? should I create module and inherit it? Thanks ...

binding inherited objects to c# datagrid

hi, Considering the following classes: class A : Idata { private int _id; //other private fields public int Id { get { return _id; } set { _id = value; } } //other property } class B : A { private int _field; //other private fields public int Field ...

C# Generics Inheritance

I have the following class public class AccountingBase<TItemType> where TItemType : AccountingItemBase And in my AccountingItemBase i have the following property: public virtual AccountingBase<AccountingItemBase> Parent { get; set; } in my AccountingBase, I am trying to do the following item.Parent = this; Logically this should ...

Django: Accessing child class of an abstract model

I have several user profile models inherited from one base class like this: class BaseProfile(models.Model): user = models.ForeignKey(User) name = models.CharField(max_length=100) ... class Meta: abstract = True class DoctorProfile(BaseProfile): license_no = models.CharField(max_length=10) ... class Pha...

How to reclassify Perl object

I'm working with a few Perl packages, we'll call them Some::Parser and Some::Data. A Some::Parser object has methods to return objects of type Some::Data. I have written a class that extends the Some::Data class, let's call it My::Data. Objects of class My::Data are really just objects of class Some::Data, but with additional methods tha...

Parcelable and inheritance in Android

I got an implementation of Parcelable working for a single class that involves no inheritance. I have problems figuring out the best way to implement the interface when it come to inheritance. Let's say I got this : public abstract class A { private int a; protected A(int a) { this.a = a; } } public class B extends A { priv...

Problem with extending a Class

I'm having a problem extending a class which itself further extends a abstract class. The base abstract class has the following methods: Abstract: private final __construct() abstract protected function loadFromId() private static final load($id) Class 1 extends Abstract: protected loadFromId() Class 2 extends Class 1: //nothing...

AS3 check if class extends another class

In AS3, I'm trying to check whether an object is an instance of, or extends a particular class. Using something like if (object is ClassName) works fine if the object is an instance of ClassName but not if it's an instance of a class that extends ClassName. Pseudo-code example: class Foo {} class Bar extends Foo {} var object = new Ba...

javascript inheritnace problem

I have two objects, and one inherites from the other. the parent object sends an ajax request to send some contact email. if i use the child to send the request, all data is empty ... why is that? the ajax request is sent (to the right url as well) but the data object is empty. var contact_A = function(){ var self = this; this....

Some pointers in designing an OO package to link into an exisiting system

Hey everyone, I'd like a few pointers as to a very specific situation i'm in regarding desigining and implementing a package in Java in an object-oriented manner. I hope i can get the idea across in a clear and not so sophisticated manner - or maybe not. Any ideas on useful design patterns to look at? Here goes.. The outline of the pr...

c# permanent casting to a subclass

If: class Car : Automobile {} I can do: Car toyota = new Car(); Automobile tauto = (Automobile)toyota; but if I do tauto.GetType().Name it will still be Car. Is it possible to perform a cast, so that the type is permanently changed to Automobile (without having to clone the object) ? The problem i am trying to overcome is that...

Reference the inherting class from the abstract class

Is there a way to reference the class (i.e. Type) that inherits a abstract class? class abstract Monster { string Weakness { get; } string Vice { get; } Type WhatIAm { get { /* somehow return the Vampire type here? */ } } } class Vampire : Monster { string Weakness { get { return "sunlight"; } strin...

C++: Storing childs of a class in variables with it's type

I am currently working on a 2D game project and I want to switch from Delphi to C++. In Delphi, I could declare an array which had the type of a class Entity, and I could put Entitys as well as objects of classes which are derived from Entity into it. This would be very important for me, as it seems logical that all entities should be ...

Typcasting vector<object> in C++?

I have two classes, obstacle and boid, boid inherits from obstacle. Now I want to write some functions that can work with objects of both classes, so that passing vector<boid> does work as well as vector<obstacle>. When I typecast like this and try to access the size of the vector I get a number of 1840700394 instead of 60: vector<boi...

Where is my base created?

If I have: struct Base { }; struct Derived : Base { }; And I create Derived in main: Derived* d = new Derived; where (on heap or on stack) is my base created? Am I reasoning correctly that a Base is a part of a Derived so it is created wherever Derived is created? Or does it work in some other way? ...