Questions tagged [abstract]

abstract is a keyword shared by a multitude of object-oriented programming languages. Methods and classes can be marked abstract to indicate that they do not contain the full implementation of application logic and have to be extended. Abstract classes can not be instantiated and serve the purpose of providing a uniform interface for their subclasses, as well as the implementation of common methods that don't have to be reimplemented for each subclass.

abstract is a keyword shared by a multitude of object-oriented programming languages.

Methods and classes can be marked abstract to indicate that they do not contain the full implementation of application logic. Abstract classes can not be instantiated and serve the purpose of providing a uniform interface for their subclasses, as well as the implementation of common methods that don't have to be reimplemented for each subclass.

The exact meaning of abstract depends on the programming languages in question, some of them being: Java, C#, php, C++, Delphi Pascal. Similar logic can also be implemented using different keywords in other languages ( for example, Oracle PL/SQL allows to create abstract classes and methods by declaring them NOT FINAL)

The power of abstract methods and classes is widely used by design patterns.

2521 questions
21
votes
10 answers

Static classes in PHP via abstract keyword?

According to the PHP manual, a class like this: abstract class Example {} cannot be instantiated. If I need a class without instance, e.g. for a registry pattern: class Registry {} // and later: echo Registry::$someValue; would it be considered…
Boldewyn
  • 81,211
  • 44
  • 156
  • 212
21
votes
5 answers

How can I force inheriting classes to implement a static method in C#?

All I want to do is make sure that child classes of the class Item implement a static method and I want this to be checked at compile time to avoid runtime errors. abstract classes with static methods don't seem to work: ERROR: A static member …
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
21
votes
4 answers

Why do I have to re-declare overridden functions in derived classes in c++?

Suppose I have the following code: class Iinterface { virtual void abstractFunction()=0; }; class Derived : public Iinterface { void abstractFunction(); // Do I need this line? }; Derived::abstractFunction() { // implementation here } If…
atoMerz
  • 7,534
  • 16
  • 61
  • 101
20
votes
1 answer

Typescript access static attribute of generic type

I have an abstract class Model with a static attribute and another generic class Controller. I want to access the static attribute of Model in an instance of Controller. That should like this: abstract class Model{ static…
Johannes Kees
  • 353
  • 2
  • 6
19
votes
3 answers

List of abstract class

I have abstract class: public abstract class MyClass { public abstract string nazwa { get; } } And two classes which inherit from MyClass: public class MyClass1 : MyClass { public override string nazwa { get {…
Pieniadz
  • 653
  • 3
  • 9
  • 22
19
votes
2 answers

PHP: Can I declare an abstract function with a variable number of arguments?

I want to be able to declare an abstract function in an parent class, with an unknown number of arguments: abstract function doStuff(...); and then define an implementation with a set of hinted arguments: /** * @param int $userID * @param int…
user668660
19
votes
3 answers

Hibernate @SQLDelete sql not adding schema

I am trying to use the @SQLDelete annotation of Hibernate to make soft deletion. It works well when the DB schema is static, i.e: passing it in the SQL. Unfortunately, it seems the SQL is passed as is to EntityPersisters (cf EntityClass's method…
Laabidi Raissi
  • 3,263
  • 1
  • 22
  • 28
19
votes
3 answers

C# abstract class static field inheritance

I feel like I skipped a C# class or two, but here's my dilemma: I have an abstract class from which I derive multiple child classes. I know for sure that for each of the child classes I will have a constructor that needs a certain static object as a…
cantrem
  • 616
  • 2
  • 8
  • 20
19
votes
3 answers

Calling a public, static function in an abstract class

I guess this question is geared more towards the language-geeks. I have the following class:
Danny Kopping
  • 4,862
  • 2
  • 29
  • 38
19
votes
3 answers

Why do we need abstract classes in Java?

Why do we need abstract classes in Java? If you're never going to make it into an object, why have it in the first place? How do you use it? Why is it there? I'm wondering the same thing with abstract methods. I find it seems like a similar concept…
user3314801
  • 417
  • 2
  • 4
  • 7
18
votes
4 answers

Abstract Class in Delphi

I am using a component suite which has many abstract classes. Now I want to apply polymorphism but I am getting Error Abstract Class when I create my object. Should I override all methods which are virtual even if I don't need it? Are there any…
marcostT
  • 573
  • 1
  • 10
  • 20
18
votes
1 answer

Typescript abstract property

I started learning typescript a few days ago. I know all the major OOP concepts, but I just don't understand the concept behind abstract properties. I understand that you have to override/implement the abstract members of your base class in the…
Adam8899
  • 231
  • 1
  • 2
  • 7
18
votes
8 answers

protected data in abstract class

My question involves specifically Java, abstract classes, and the use of protected data. I am being told that all the data should be private, and protected getters/setters used only. Now, I understand we want to shield data from direct manipulation…
cvsdave
  • 1,576
  • 2
  • 12
  • 18
18
votes
2 answers

Best method of including an abstract in a latex 'book'?

I've been looking for the answer to this question for a while now but can't seem to find it, so I'm hoping someone on here can help me. I'm writing up a thesis in Latex, and really like the \frontmatter, \mainmatter and \backmatter ability when…
olan
  • 3,568
  • 5
  • 24
  • 30
18
votes
4 answers

How to find where an abstract method is implemented in Eclipse?

I would like to find where an abstract method is implemented, in which class? Is there a link in Eclipse like call hierarchy/open declaration or something like that that shows where the method implemented is?
ZelelB
  • 1,836
  • 7
  • 45
  • 71