abstract

Android abstract activity in manifest

…衆ロ難τιáo~ 提交于 2019-12-22 08:02:55
问题 For my application I am going to create a variety of abstract classes that extend the android.app.Activity and android.app.Service classes. When I subclass my abstract classes how do I add them to the android manifest? Do I need to add both the abstract class and my sub class to the manifest or just the subclass? Do they need to be in the same package? 回答1: You add the final subclasses to the manifest as regular Activities/Services; the abstract classes don't need to be there, as the manifest

abstract method in a virtual class

≯℡__Kan透↙ 提交于 2019-12-21 18:34:12
问题 I have a c# Class that has lots of virtual methods, some of these methods are essentially abstract ( they are fully implemented in subclasses and the base class is empty). To get it to compile i am throwing an InvalidOperationException in the base class with a comment on what should be done. This just feels dirty. Is there a better way to design my classes? edit: It is for the middle tier of an application that will be ran in canada, half of the methods are generic hence the virtual. and half

How do I initialize a Graphics object in Java?

喜欢而已 提交于 2019-12-21 05:26:09
问题 this is the code: import java.awt.*; import java.applet.*; public class anim1 extends Applet{ public void paint (Graphics g) { g.drawString("",400,300); } public static void main(String ad[]) { anim1 a=new anim1(); Graphics g1; a.paint(g1); } } It says that g1 is not initialized. But how do I initialize an abstract class? 回答1: Well there are two issues here 1: Graphics g1; a.paint(g1); And you are getting the error that G1 is not initialized. That's because the variable g1 is never set to

DataContract Serialize abstract class

孤者浪人 提交于 2019-12-21 01:20:16
问题 I have an interface IServiceInfo and an abstract class ServiceInfo. There are several classes inherited from ServiceInfo, like CoreServiceInfo, ModuleServiceInfo etc. There is a service contract named RootService which returns IServiceInfo. public IServiceInfo GetServiceInfo() { return (IServiceInfo)new CoreServiceInfo(); } I am having problem serializing. I can use ServiceKnownType to identify base class, and KnownType to identify child class. Problem is I do not know all the ServiceInfo

A pointer to abstract template base class?

这一生的挚爱 提交于 2019-12-20 12:35:32
问题 I cannot figure this out. I need to have an abstract template base class, which is the following: template <class T> class Dendrite { public: Dendrite() { } virtual ~Dendrite() { } virtual void Get(std::vector<T> &o) = 0; protected: std::vector<T> _data; }; Now, I derive from this which specifies exact usage of Dendrite. Now the problem. How do I create a vector of pointers to the base-class with no specific type, which I want to specify by pushing elements to it later? Something like: class

The designer must create an instance of…cannot because the type is declared abstract

孤者浪人 提交于 2019-12-20 10:18:33
问题 Visual Studio complains: Warning 1 The designer must create an instance of type 'RentalEase.CustomBindingNavForm' but it cannot because the type is declared as abstract. Visual Studio won't let me access the Designer for the form. The class already implements all abstract methods from the CustomBindingNavForm. CustomBindingNavForm provides some functions concrete and abstract. Is there a way around this? Here is the class: public abstract class CustomBindingNavForm : SingleInstanceForm { /

Java: static abstract (again) - best practice how to work around

﹥>﹥吖頭↗ 提交于 2019-12-20 09:49:20
问题 I theoretically understand the point why there is no abstract static in Java, as explained for instance in Why can't static methods be abstract in Java . But how do I solve such a problem then? My application uses files of a few types, which I want to assign static properties like a description of that file type (like "data file", the other being "config file", etc.). Obviously, I would put that into a static String so that the description is accessible without instancing a file (useful for

Comparison : interface methods vs virtual methods vs abstract methods

情到浓时终转凉″ 提交于 2019-12-20 08:34:01
问题 What are the advantages and disadvantages of each of these? interface methods virtual methods abstract methods When one should choose what? What are the points one should keep in mind when making this decision? 回答1: Virtual and abstract are almost the same. A virtual method has an implementation in the base class that can optionally be overridden, while an abstract method hasn't and must be overridden in a child class. Otherwise they are the same. Choosing between them depends on the

Work around the need to override abstract methods in Java?

扶醉桌前 提交于 2019-12-20 05:16:13
问题 I've been working on an assignment that involves an abstract class that represents a generic animal, with subclasses for cat, dog, reptile, etc. The superclass has abstract methods that aren't actually used by each subclass. For example, there are accessors and mutators for breed and gender that are used by dog and cat but not the reptile class. I personally think this is an odd setup, but it's what is required by the assignment. At first I tried leaving out the abstract methods not used in a

Overriding an abstract method with a virtual one

冷暖自知 提交于 2019-12-19 18:20:13
问题 I'm trying to override an abstract method in an abstract class with a virtual method in a child class. I (assumed until now?) understand the difference between abstract and virtual methods. Obviously I'm not able to do it but my question is... why? Based on the accepted answer here and the following scenario, I just don't see the problem: public abstract class TopLevelParent { protected abstract void TheAbstractMethod(); } public class FirstLevelChild1 : TopLevelParent { protected override