subclass

Incompatible return types for method when returning subclass

不羁岁月 提交于 2019-12-11 01:16:23
问题 I am trying to define a method to return all neighbours of a given vertex on a graph given by the signature public abstract class GraphClass<V extends Vertex<?>,E extends Edge<V,?>> implements UndirectedGraph<V,E>{ . . . public ArrayList<V> getNeighbors(V v) {...} } I wish to override this method from my KTree class which extends the above GraphClass as follows public class KTree extends GraphClass<KVertex,KEdge> {... public ArrayList<KVertex> getNeighbors(KVertex v) { return v.getAdjList();

How to display a Subclass of UIControl on the screen

扶醉桌前 提交于 2019-12-11 00:37:53
问题 I have created a subclass of UIControl called ToggleImageControl via the following code (with reference to the following post Checkbox image toggle in UITableViewCell) @interface ToggleImageControl : UIControl { BOOL photoIsStarred; UIImageView *imageView; UIImage *normalImage; UIImage *selectedImage; } @property (nonatomic, assign) BOOL photoIsStarred; @property (nonatomic, retain) UIImageView *imageView; @property (nonatomic, retain) UIImage *normalImage; @property (nonatomic, retain)

Making a variable final and static in one subclass, while keeping it variable in others in Java

你离开我真会死。 提交于 2019-12-10 23:52:07
问题 I have a superclass and two subclasses that extend it. I'd like to initialize a variable called radius which can be set freely in subclass A, but is always the same for subclass B. I could initialize the variable every time I create an object B, but I was wondering if it's possible to make the variable final and static in subclass B, while still being able to implement a getter in my superclass. I might implement more subclasses which have a radius that's either final or variable. If not I'm

In python 2.x should I call object.__del__?

牧云@^-^@ 提交于 2019-12-10 21:29:31
问题 In Python 3.x all classes are subclasses of object . In 2.x you have to explicitly state class MyClass(object) . And, as I'm trying to write as much 3.x compatible code as possible, I'm subclassing object . In my program, I'm using the __del__ method, and I wanted to know if I should be calling object.__del__(self) , or if that's magically taken care of? Thanks, Wayne EDIT: It appears there is some confusion what I mean - in the documents it states: If a base class has a __del__() method, the

C# override/add methods/fields to an object

梦想的初衷 提交于 2019-12-10 19:52:37
问题 I have a library that creates and setups objects for me, then I can use those objects to do stuff. Let's say I'm given object "a" of class "A" So I want to override a method in that specific object, I don't want to change the code of its class because that would require changing the library. In Ruby I can do that using Singleton Classes, like: class FirstClass def test p "test" end end o = FirstClass.new class << o def test p "overridden" end def extraMethod p "ok" end end o.test # prints

Pass abstract parameter to method, why not?

六月ゝ 毕业季﹏ 提交于 2019-12-10 18:10:03
问题 I've written an abstract class (with pure virtual functions), and I'd like to have a method accept one such class as a parameter. Given that the class is abstract, I understand that I couldn't pass an abstract class to any method, but why can't I pass a subclass of an abstract class to that method? How do I specify that a parameter should be any of the subclasses of a specified baseclass? This is all in C++. 回答1: You need to specify the parameter as a pointer (or reference), e.g. Abstract *

Get instance of subclass with superclass static method

穿精又带淫゛_ 提交于 2019-12-10 17:45:25
问题 I have a superclass that I would like to forward a static method called getInstance() to all subclasses. When creating an instance of a subclass, I then register the instance in the superclass (perhaps using a hashtable, where the key is based on getClass() ). Then, I wish to use the aforementioned static method ( getInstance ) where the superclass method will return the instance of the correct type. For example, I have a superclass A, and a subclass B extends A. I want to write a static

Can @ManagedBean and @XxxScope be placed in a base class?

萝らか妹 提交于 2019-12-10 17:28:28
问题 I have two @ManagedBean (javax.faces.bean.ManagedBean), parent and child. The parent managed bean is not abstract because we have to give liberty to the developer to use the parent if enough or inherit it with a child that holds specifically funcionality. I have problems with the injections bean and the @PostConstruct annotated method in the parent bean. The following code is the only way I found it works. @ManagedBean(name = "myBean") @SessionScoped public class BaseBean implements

UIControl subclass is unable to take a target?

孤者浪人 提交于 2019-12-10 17:19:15
问题 I've subclasses UIControl and in it I am sending: [self sendActionsForControlEvents:UIControlEventValueChanged]; When I create an instance of the object, I add a target as follows: [starView addTarget:self action:@selector(starRatingChanged:) forControlEvents:UIControlEventValueChanged]; The view shows up fine, and without the target being there the functionality works well. But with adding the target, it crashes. Any ideas why? My class is declared with: @interface RMStarRating : UIControl {

How to create multiple windows with the same nib file in xcode

痞子三分冷 提交于 2019-12-10 16:14:17
问题 I have an iphone app that uses table view as the interface. Each time that the user taps on one of the table cells, I want to show another window to the user. However the user interface of the window that I push into the navigation controller are extremely similar. Therefore I decided to make a "generic nib file" to be used across all the subclasses of the file owner of this generic nib file. However what I'm confused (and what's not working) is that I can't seem to be able to customise this