Questions tagged [abstract-class]

Abstract classes are classes which cannot be instantiated. They exist to provide common functionality and interface specifications to several concrete classes.

Abstract classes are classes which cannot be instantiated. They exist to provide common functionality and interface specifications to several concrete classes.

From Abstract Type on Wikipedia:

Abstract classes can be created, signified, or simulated in several ways:

  • By use of the explicit keyword abstract in the class definition, as in Java, D or C#.
  • By including, in the class definition, one or more methods (called pure virtual functions in C++), which the class is declared to accept as part of its protocol, but for which no implementation is provided.
  • By inheriting from an abstract type, and not overriding all missing features necessary to complete the class definition.
  • In many dynamically typed languages such as Smalltalk, any class which sends a particular method to this, but doesn't implement that method, can be considered abstract. (However, in many such languages, the error is not detected until the class is used, and the message returns results in an exception error message such as "does Not Understand").
5262 questions
2
votes
2 answers

Inheriting a non-abstract class and turning all of its functions into abstractmethods

An upstream interface was given to me with all of its functions defined as non-abstract when in reality they should be decorated with @abstractmethods. I want to receive an error when I did not implement one of its functions when it's called. To do…
OneRaynyDay
  • 3,658
  • 2
  • 23
  • 56
2
votes
1 answer

Use HATEOAS RepresentationModel in parent abstract class

I t tried use new lastes version of Spring Hateoas 1.0 in my Spring Project, in this project all entities classes inherit from an Abstract Class, but in the Hateoas documentation my Entities must be extend the RepresentationModel Class…
Jericob
  • 1,947
  • 2
  • 14
  • 16
2
votes
1 answer

IntelliJ reporting that abstract class is missing implementation of concrete method, but method is implemented in abstract class?

I have an abstract Dart class which contains some abstract methods and a concrete, implemented method that I want to keep consistent across all subclasses. IntelliJ's Dart Analysis system is reporting in subclasses that no concrete implementation…
Adam
  • 146
  • 1
  • 15
2
votes
3 answers

Creating a clone of an abstract Class

I am writing a chess program and I have an abstract class named Pieces. I use this abstract class in my main class by using a pointer, like such: Pieces * newset = currentboard[][]; If I make moves on this board the moves are actually made. I want…
GeeKaush
  • 33
  • 1
  • 6
2
votes
2 answers

How do I change this superclass into an abstract class without getting an instantiation exception?

I want to make my superclass an abstract class, however I am getting various exceptions when trying to do so (InstantiationException, RuntimeException, InvocationTargetException). My code works when I do not have my superclass as abstract. How do I…
zehFlowr
  • 21
  • 2
2
votes
6 answers

is the Interface on its way to be obsolete soon?

as I found, an abstract class is an interface when it has zero implementation in it. am I right ? then why there are interface classes in some languages, I mean C++ doesnt have an interface. is it going to be obsolete someday soon ?
Arrabi
  • 3,718
  • 4
  • 26
  • 38
2
votes
1 answer

Abstract Windows.Forms.Panel possible in C#?

I am trying to create a program that has multiple layers of controls all drawing on top of each other. The way I'm doing this is that I have a windows.forms.panel that is a container for the panels doing the actual drawing (this way I can layer…
simpleCoder
  • 152
  • 2
  • 13
2
votes
1 answer

Deserialization abstract class implementation .Net Core C#

Short explanation: Project in Angular and .NetCore where I try to update a list of abstract classes in my backend. By creating a put request I update the container model which holds the list I want to update. The frontend serialises the container…
2
votes
1 answer

How can I arrange multiple classes with abstraction?

How can I arrange multiple classes with abstraction? So, there would be one Base abstract class and other three classes would extend Base abstract class. The idea is to create an abstract class with all product common logic, like getTitle,…
2
votes
1 answer

Xamarin iOS Binding - Protocol - Cannot Create Instance of Abstract Class

I've generated some binding code using Sharpie for the Zebra Scanner SDK. Zebra Scanner SDK The generated code builds fine once I've processed the [Verify] attributes. The starting point for the SDK is to call a static method on the SDK factory…
2
votes
1 answer

When to declare protected fields in abstract class cpp

I feel very uncomfortable with the concept of abstract classes, and I'd be happy if someone could make it a bit clearer. I do understand that it's also a matter of implementation and personal style, but I'd like to have at least some guidelines to…
E. Ginzburg
  • 253
  • 2
  • 9
2
votes
2 answers

How to cast abstract class to non-abstract class?

If I have an abstract class Adapter {}, I'd like to create a function which accepts a non-abstract constructor extending this class and returns a new instance of the class. e.g. export abstract class Adapter {} export function…
John
  • 9,249
  • 5
  • 44
  • 76
2
votes
1 answer

Inherit wrapper from abstract method

I would like to systematically wrap some overriden method of a base class. I am using ABC for the base class. I tried to wrap the @abstractmethod, putting the annotation before or after, but it doesn’t work. As I understand it, the the whole wrapped…
Silver Duck
  • 581
  • 1
  • 5
  • 18
2
votes
1 answer

What is the best practice of inheriting constants in Java?

I have an abstract class that has some constants that each child class will use. Each one of them is static, final and immutable. public abstract class MyAbstract { //some private instance fields protected static final long LONG_ID = 1; …
Ava
  • 818
  • 10
  • 18
2
votes
3 answers

Throwing an exception from an abstract Runnable.run() in Java

I've made an abstract Thread that processes some streams in its run() method. I'd like to be able to have the subclasses handle these exceptions rather than the abstract parent class, but I don't know the most elegant way to do that. Right now, I'm…
Wind Owl
  • 23
  • 1
  • 4