Abstract type: Difference between revisions
Content added Content deleted
(added c++) |
|||
Line 36: | Line 36: | ||
</ada> |
</ada> |
||
Here Node is an abstract type that is inherited from Limited_Controlled and implements a node of a [[Doubly-Linked List (element) | doubly linked list]]. It also implements the interface of a queue described above, because any node can be considered a head of the queue of linked elements. For the operation Finalize an implementation is provided to ensure that the element of a list is removed from there upon its finalization. The operation itself is inherited from the parent type Limited_Controlled and then overridden. The operations Dequeue and Enqueue of the Queue interface are also implemented. |
Here Node is an abstract type that is inherited from Limited_Controlled and implements a node of a [[Doubly-Linked List (element) | doubly linked list]]. It also implements the interface of a queue described above, because any node can be considered a head of the queue of linked elements. For the operation Finalize an implementation is provided to ensure that the element of a list is removed from there upon its finalization. The operation itself is inherited from the parent type Limited_Controlled and then overridden. The operations Dequeue and Enqueue of the Queue interface are also implemented. |
||
=={{header|C++}}== |
|||
You can declare a virtual function to not have an implementation (called "pure virtual function") by the following "<code>= 0</code>" syntax after the method declaration. A class containing at least one pure virtual function (or inheriting one and not overriding it) cannot be instantiated. |
|||
<java>class Abs { |
|||
public: |
|||
virtual int method1(double value) = 0; |
|||
virtual int add(int a, int b){ |
|||
return a+b; |
|||
} |
|||
};</java> |
|||
Because C++ allows multiple inheritance of classes, no distinction is made between interfaces and abstract classes. |
|||
=={{header|Java}}== |
=={{header|Java}}== |