c#,compare,abstract-class,icomparer
I want to create and abstract class A that implements IComparer so that I can implement different forms of comparing in the subclasses and later on do: A sortBy = new B(); A sortBy2 = new C(); I'm new in C# and I don't quite get how to do that....

c++,abstract-class,pure-virtual
I am trying to make a system like Java's swing, where you have a window, and that window has multiple components, such as Labels (text/images), Text Boxes, Check Boxes, etc. The way swing works is that there is a Component class, which is abstract, which has an abstract paint method,...

java,inheritance,nullpointerexception,abstract-class
I have an abstract class that declares a number of object references, specifically a JLabel. I have two classes that both extend that class. One of the children instantiates the JLabel and calls a couple of its methods. That classes sibling attempts to call the setText method on the JLabel...

java,abstract-class
I have a method String foo() in an abstract class which already does a few precomputations but can't deliver the final result the method is supposed to return. So what I want is that each non-abstract class inheriting from my abstract class has to implement foo in a way that...

java,arrays,object,abstract-class,copy-constructor
I have an abstract class Specie, and then class Animals which extends species, and then my classes for animals (e.g. Sheep). In Animals I have a method which checks if two objects are on the same position on the map, and if the are the same type (e.g. Sheep and...

java,interface,abstract-class,implementation
I have an interface with several methods. I then have an abstract class that defines some of those methods, but also leaves some of the methods abstract. Now I have a class that extends the abstract class. Do I need to write all the methods from the original interface and...

java,iterator,abstract-class,inner-classes,extends
I'm frustrated, trying to add methods to a custom iterator. For an assignment in my second quarter Java class, we are supposed to implement, from scratch, a linked list. No problem: I have created an outer class to implement the linked list and a static private inner class to implement...

java,c#,interface,field,abstract-class
public interface IHashStorage<T> { public static final float INITIAL_LOAD_FACTOR = 0.7f; public static final int INITIAL_CAPACITY = 149; } I have the code above which needs to be translated in c#. The only solution that seems to be proper is to make it an abstract class.From what I found it's...

c++,inheritance,c++11,clang,abstract-class
Main Question I am trying to build a clang plugin as per the instructions here, but I am encountering linker errors when I try to build. These are the errors: /tmp/Test-1ea47e.o: In function `ASTFrontendAction': /usr/lib/llvm-3.4/include/clang/Frontend/FrontendAction.h:216: undefined reference to `clang::FrontendAction::FrontendAction()' /tmp/Test-1ea47e.o: In function `~TestPlugin': /home/path/to/plugin/Test.cpp:12: undefined reference to `clang::FrontendAction::~FrontendAction()' /tmp/Test-1ea47e.o:(.data.rel.ro+0x20): undefined...

java,class,design-patterns,methods,abstract-class
What would be an example of template method design pattern for image objects, or different types of image like: BufferedImage, Image, ImageIcon. I only need java class methods and their signatures and fields i don't need real functional code. this would be based on the fact that different types of...

java,abstract-class,method-overriding
Say that I have two, abstract methods in an abstract base class: protected abstract void writeData(OutputStream stream); protected abstract void writeData(Writer writer); When I make an implementation, I have to override these methods so that when the data needs to be written, it knows how to do it. What I...

c#,abstract-class
I would really appreciate any help with the following scenario that I'm working on and wasn't able to find a solution for. My apologies if the title does not match up with the current lingo too. The following code is an example that I'm working: public class SumObject { public...

c#,json,generics,interface,abstract-class
I believe this question is answered simply, but since I've been banging my head on this issue for a while, I've might have trouble seeing the overall picture. I want to load multiple files (in this case, JSON), so I created a DataLoader class that will handle this. In this...

c#,linq,lambda,closures,abstract-class
I found some duplicate code today and would like to reduce it to one method. In order to do it, I'd like to inject something more abstract into the lambda here: public IEnumerable<AbstractFoo> GetMatchingFoos() { return IEnumerable<AbstractFoo> exactMatchFoo = exactMatchList .Where (d => d is RedFoo); } //Horrifying duplicate code!:...

php,arrays,oop,properties,abstract-class
i'm somewhat new in using Abstract Classes and OOP so please bear with me. I'm trying to make a list of Employees and Customers but im running into a bit of trouble printing out the array of objects in my StoreList class since they are all protected. What i want...

c#,dependency-injection,abstract-class
I am designing a class that uses an abstract property to provide a point of access to a field. Here is a snippet of my code: public abstract class PageBroker : WebBroker { public abstract IPageProvider Provider { get; } } public class ArticleBroker : PageBroker { public override IPageProvider...

java,abstract-class,factory-method
abstract class IntBuffer seems like you can't create an instance of this class anyway , because its declared abstract but at the same time , there's a static factory method IntBuffer allocate(int capacity) and now you can create an instance by simply Buffer b=IntBuffer.allocate(128) but wait, IntBuffer was abstract and...

c++,iterator,abstract-class,nested-class
My code structure is as follows. I have a base abstract class which also has a nested abstract iterator. I inherit from the base class and i also inherit from the abstract base inherited class. To allocate the objects I use polymorphism: i am getting errors like: In file included...

c++,oop,abstract-class,base-class,abstract-base-class
Is an Abstract Class the same thing as a Base Class? I occasionally see the term Base Class, but when I look up what it means, I tend to see "Abstract Class" thrown around. Are they just two words that mean basically the same thing?...

java,abstract-class
I have the following need and please help me to write good and abstract class. Different types of operations is needed based on the type I have a abstract class, abstract public class FileHelper{ //Template method //This method defines a generic structure for parsing data public void parseDataAndGenerateFile(String fileDownloadType) {...

vb.net,oop,object,interface,abstract-class
I have an idea that uses both an abstract class and an interface, but i'm not sure if its possible to do what I am thinking of and how. I have an abstract class modeling a device, containing only abstract functionality. When implemented this class basically serves as a driver...

ios,iphone,uiimageview,uiimage,abstract-class
I am trying to override getter of ImageView to return placeholder image if imageView not settled, But I have error and I can not do it. Why this happens and how can I solve this problem? My code @implementation OvalImageView - (UIImage *)image { return _image? _image : [UIImage imageNamed:@"avatar-big-placeholder"];...

java,interface,polymorphism,abstract-class
So this is more of a question of curiosity rather than needing an issue solved, I think. So I am sitting with AndEngine for Android in Android Studio and I want to make a AudioManager to handle all my audio, as a start. I could implement AndEngine's interface called IAudioManager...

java,abstract-class
I have two questions. I have an Apple class that extends an abstract Fruit class see code below ↓ First question: Why do I have to use the import java.awt.Color; in my apple class, since it's already in my Fruit class? I get an error: cannot find symbol Second question:...

scala,abstract-class
I know that abstract classes can't be instantiated, so maybe I'm answering my own question, but is there a way to put a private constructor in an abstract class? My problem is I have an abstract class with two subclasses that have the exact same methods, and some of the...

c++,c++11,inheritance,abstract-class
Is it possible to have an abstract class but FORCE implementing classes to have only the public methods that are in the abstract class? I don't care how the private methods work, but I want to force the classes to have only one public method. For example, say I have...

java,abstract-class
First of all, pretty new in java, sorry if it is a simple question. I have implemented an abstract class, and two classes that extends it. public abstract class Lado{ //body } and the two other classes with this form for example public class Arista extends Lado { //body }...

php,oop,abstract-class
I want to use variable value from one function into another function of same class. I am using abstract class using which I am declaring variable as global indirectly. I can not declare variable as global in the class. My demo code is as follows: <?php abstract class abc {...

java,abstract-class,implements
After calling doReading(),the value of pages is supposed to change, but it does not. Is it possible to do this without declaring int pages; in the MyMath2 and MyScience2 classes. The output should be something like: Before reading: Math- must read 5 pages After reading: Math- must read 3 pages...

java,oop,abstract-class,abstract
This could be a useless question, Just out of my curiosity. Why we are forced to add the keyword abstract in front of abstract method of abstract class, when we don't need to add the keyword in case of interface. The possible answer could be: As abstract class are mixed...

java,abstract-class
I have abstract class which is having a variable at class levele.Now i want to use this variable in other class.How can i achieve it? Following is my code public abstract class MyClass { String name="John"; } ...

ios,swift,oop,abstract-class
Swift has no abstract classes and methods. Instead, it offers protocols. That's fine when your classes are either fully abstract or fully concrete. But what is the best 'Swift' way to implement an abstract class that also has concrete methods? Pseudo-code example: class Animal { abstract makeSound() abstract eyeCount() }...

java,abstract-class,method-overriding
I use a library where an abstract class overrides a concrete method inherited from Object with an abstract method: public abstract class A { @Override public abstract boolean equals(Object obj); } To extend this class, I have to implement the equals method: public class B extends A { @Override public...

java,android,libgdx,abstract-class
I want to use an abstract screen for my LigGDX game. I have read many websites and many of them use abstract screen only to group the common codes (e.g. common methods) together. If this is the case, we can simply use a normal class to do the task. The...

java,arraylist,override,abstract-class
I have an abstract class "Homework"and 4 other classes that extend it (I only pasted one of them since they are identical). The program compiles, but the output looks like this: null - must read 0 pages null - must read 0 pages null - must read 0 pages null...

unit-testing,junit,mocking,mockito,abstract-class
In a class under test, if its constructor takes in an abstract class parameter can we mock it using mockito? Ex public abstract AbstractClass{ } //Class under test public class SourceClass{ SourceClass(AbstractClass abstractClass){} } @RunWith(MockitoJUnitRunner.class public SourceClassTest{ @Mock AbstractClass abstractClass; } whenever I do this i get this error java.lang.ExceptionInInitializerError...

java,abstract-class
I read this task and I am confused as to how I should start it because I don't fully understand sub classes :(. Can someone help me get started with the code? Thank you :). The Task: Create an abstract class Book with two subclasses: Fiction and NonFiction. NonFiction should...

php,class,object,abstract-class,static-methods
I have an abstract class that has a method which uses a static function. This static function is defined in sub-classes and is different for each sub-class. Which sub-class will be used to create object is determined in the script. See super simplified code below: abstract class fooClass implements iFooClass...

java,inheritance,abstract-class
So i was just trying to learn java coming from a C++ background, as part of a quick ramup I just implemented a base class from a abstract class as below abstract class my_abstract_class { abstract void my_abstract_function(); } class my_concrete_class extends my_abstract_class { } public class ConcreteClasses { public...

java,abstract-class,object-construction
I have an abstract class and its concrete subclass, when I create an object of subclass it automatically calls the super constructor. Is the JVM internally creating an object of the abstract class? public abstract class MyAbstractClass { public MyAbstractClass() { System.out.println("abstract default constructor"); } } public class ConcreteClass extends...

python,python-3.x,abstract-class
This question already has an answer here: Python, invoke super constructor 3 answers How can I define a __init__ function in both the base and derived abstract classes and have all self.* be available in the abstract method? For example: What is the proper way of utilizing functions that...

c++,visual-studio-2010,inheritance,abstract-class,pure-virtual
I have an abstract base class, where some functions are implemented and some are purely virtual. From this base class, I have created a derived class which implements all virtual functions. However, it still complains that the derived class is abstract. I assume that I have forgotten to implement one...

class,inheritance,design,abstract-class
I Know Abstract is a class something else extends on but why would anything want to extend a non-abstract class? Is it generally a better convention to only extend from abstract classes as then they cant be instantiated so it doesn't do weird stuff? an example of both showing why...

java,android,android-fragments,abstract-class,abstract-methods
I'm not really sure what my problem statement is, as you can tell from the title. I have an abstract class A that extends Activity. Class A has an abstract method defined: public abstract class A extends Activity { ActionBar.Tab devicesTab, otherTab; Fragment fragmentTab = new FragmentTab(); protected abstract void...

c#,override,abstract-class,tostring
I have an abstract class Animal Looking like this abstract class Animal{ protected int numberOfPaws; public abstract String speak(); public String toString(){ return "I have " + numberOfPaws + " paws"; } } Then I have a derived class that has a new implementation of toString() looking like this class...

java,abstract-class,abstract
I have a super-class A with an abstract inner-class Inner, with another class B that extends A. Why doesn't A force B to implement the abstract inner-class? I've already looked here, but it only specifies abstract methods in non-abstracts classes. Does the same principle apply here? public class A {...

java,inheritance,enums,abstract-class
I have the following problem. I have a package with different enumeration classes in java. What is the correct approach to avoid repeting myself when adding new methods that are common to all enums? My problem: channel.java public enum Channel { channel1, channel2; } color.java public enum color{ color1, color2;...

python-3.x,abstract-class,abstract,abc
I was trying out the below python code: from abc import ABCMeta,abstractmethod class Bar: __metaclass__ = ABCMeta @abstractmethod def foo(self): pass class Bar2(Bar): def foo2(self): print("Foo2") b=Bar() b2=Bar2() I thought having @abstractmethod will ensure that my parent class will be abstract and the child class would also be be abstract...

android,abstract-class,final
For the moment, I created an abstract class like this: public abstract class MyClass { public final static String TAG; ... } But it gives me an error of not initializing a final variable. Then I tried to initialize it from a constructor, but it didn't work either (gives the...

c#,database,generics,inheritance,abstract-class
I am working on a C# project that is pulling data from SQL Server, ODBC data-sources and Oracle Databases at different times. At this point, I have created 3 different classes - Once for each type of DB access. However, I am seeing that 95% of the code is identical...

c++,interface,operator-overloading,abstract-class
I want to have an abstract class IMatrix which contains pure virtual members and one of them is an operator overloading member. template <typename T> class IMatrix { public: virtual T operator+(const T& b)=0; }; and for the implementation I want to use a third party matrix class as for...

java,oop,abstract-class
I am little confused about abstract class in java. I know that whenever there is an abstract method in the class compiler force developer to mark class abstract. But even we don't have any abstract method in the class we still mark the whole class as abstract. I am not...

java,abstract-class,private,inner-classes
I am preparing for an Oracle examination and answered incorrectly to the following question: the combination abstract private is legal for inner classes As it turns the answer is true, I answered false, as I could not find any use cases for having an abstract private inner class, that cannot...

java,inheritance,abstract-class,method-overloading,abstract-methods
I want to have an abstract class that has an abstract method, say abstract void compare(). But the parameters it takes should vary according to different implementations in different subclasses. I wonder what is the right way to do this? I cannot overload it by writing different signatures of it...

java,abstract-class
Okay, people are probably going to run to flag this as a duplicate, just by reading the title and without really reading the question. So please know that I HAVE tried to look at other questions on this platform, but have not found something that clears my doubts exactly. Kindly...

java,oop,interface,abstract-class,late-binding
I am learning how to use the Factory pattern for creating objects in Java. I want to create classes to manage Cars. A car can either be small or large. I created an interface that defines the methods to be implemented by an implementing class. An abstract class implements some...

c#,.net,inheritance,abstract-class
I am trying to setup a scenario where we can create a common set of models for our workgroup and then implement or extend them if/when needed. I have the following setup: namespace Workgroup.DomainClasses { public abstract class WorkGroupOrder { private ICollection<WorkGroupItems> _items; protected WorkGroupOrder() { _items = new List<WorkGroupItems>();...

python,python-3.x,abstract-class
What is the proper way of utilizing functions that are imported in the base class of an abstract class? For example: in base.py I have the following: import abc import functions class BasePizza(object): __metaclass__ = abc.ABCMeta @abc.abstractmethod def get_ingredients(self): """Returns the ingredient list.""" Then I define the method in diet.py:...

c#,abstract-class,inner-classes,abstraction
I have an abstract class A and a abstract method with a parameter which is again abstract class B defined in the same abstract class A. When I extended this abstract class A as apart of another class C how can I implement the method with parameter of nested abstract...

java,set,abstract-class
I am doing a project based on Set in Java, I have given a exiting project as a base. I have found the following code but could not understand what it means particularly an AbstractClass Extends itself. Any help would be appreciated. Thanks public abstract class AbstractClass<I extends AbstractClass<I, V>,...

java,interface,naming-conventions,abstract-class,java-api
In java I often find myself implementing the List interface instead of, for example, extending the AbstractList class. This is rather common in the Java API (and in many third-party libraries I've looked at), that there exists an interface and an abstract class for that interface. Why is this? Why...

java,android,layout,abstract-class
So currently I have a view <TextureView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/texture_view" android:visibility="gone" /> Which only supports Android API 14 and up ... I want to create a different view for API < 14 ... So I want create an abstract view and call it in the XML layout file <CustomView android:layout_width="match_parent"...

java,regex,parsing,polymorphism,abstract-class
So, I'm doing a regular expression parser for school that creates a hierarchy of objects in charge of the matching. I decided to do it object oriented because it's easier for me to imagine an implementation of the grammar that way. So, these are my classes making up the regular...

java,c++,c++11,callback,abstract-class
I realise that the solution I have here is far from ideal with C++, so I'm asking what a proper C++ programmer would do in this situation. (C++11) I have a DialogBox class, which stores a collection of buttons. At the moment I have a pure abstract inner class DialogBox::Button...

c++,abstract-class
I'm using capd library (http://capd.ii.uj.edu.pl/) and I have two pieces of code: C0Rect2Set set(ex.start); timeMap(ex.time, set); and C0HOTripletonSet set(ex.start); timeMap(ex.time, set); I'd like to abstract on the type of C0Rect2Set and C0HOTripletonSet. I think that both C0Rect2Set and C0HOTripletonSet are deriving from C0Set (I'm not sure about this, but that...