Questions tagged [abstract-function]

Abstract functions are functions that can not be used. They exist to provide an interface specification to several concrete classes.

For more information, see this post on virtual vs abstract: What is the difference between an abstract function and a virtual function?

7 questions
257
votes
4 answers

Difference between virtual and abstract methods

Here is some code from MSDN: // compile with: /target:library public class D { public virtual void DoWork(int i) { // Original implementation. } } public abstract class E : D { public abstract override void DoWork(int…
iJade
  • 23,144
  • 56
  • 154
  • 243
61
votes
7 answers

How to declare abstract method in non-abstract class in PHP?

class absclass { abstract public function fuc(); } reports: PHP Fatal error: Class absclass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (absclass::fuc) I want to know what it…
user198729
  • 61,774
  • 108
  • 250
  • 348
15
votes
2 answers

Why does PHP allow abstract static functions

Consider the following code: abstract class ExampleClass { public static function regularStaticFunction() { return static::abstractStaticFunction(); } abstract protected static function…
Thijs Riezebeek
  • 1,762
  • 1
  • 15
  • 22
2
votes
2 answers

Kotlin Generic abstract function

I have an abstract function, where I want to get any of my Activity Presenters in BaseActivity protected abstract fun , V : BaseView> getPresenter(): T So my function shoud accept only class that extends BasePresenter with view…
Anton A.
  • 1,718
  • 15
  • 37
1
vote
3 answers

What can a Java enum with abstract functions do that a non-abstracting version can't? (i.e. Is there a technical difference, or is it just a pattern?)

Ok, in this answer here on stack, the poster of the answer shows an example of how you can use abstract methods in an enumeration. I'll repeat that answer here for posterity, albeit slightly-modified to better illustrate the basis of my…
Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286
1
vote
2 answers

Interface and abstract public function

It seems to me that both interface and abstract function are quite similar, it's like an order that some method must be implemented, so what's the difference?
user198729
  • 61,774
  • 108
  • 250
  • 348
-1
votes
3 answers

How to declare Abstract Class?

I am trying to make abstract method clear to me , so I wrote this code and test it. But when I run it the following error appear : Fatal error: Class Book contains 1 abstract method and must therefore be declared abstract or implement the remaining…
Anasoft
  • 3
  • 8