Document directory
Code for testing
Original post address: http://www.codeproject.com/KB/cs/abstractsvsinterfaces.aspx
Original Author:Rahman Mahmoodi
Translation: 54sunIntroduction | description
I will discuss abstract class and interface through this article and the attached demo program ). These two concepts often confuse beginners of the object-oriented language. Therefore, I try to explain their d
Abstract ModifierAbstract: A class can be modified to indicate an abstract class. Note: the unique difference between an abstract class and a specific class: A
A pure virtual function (pure virtual) is a method in a base class, just a declaration, not a definition, is a generalization concept (general concept);
is to put the corresponding virtual function, the end of the Add "= 0", the virtual function becomes a pure virtual function, you can not add a definition;
If it is another virtual function, it must be defined (define), even if it is not used;
A base class
Abstract class, interface, abstract class Interface
Why use abstract classes:
If the subclass is not correctly rewritten, no prompt is displayed.
Assume that the code of the parent class is as follows:
public
Abstract classes cannot override abstract methods of abstract parent classes when they inherit another abstract class。 This usage can be understood as an extension of the abstract class
Abstract method: A method that does not have a method body in a class is an abstract method.Abstract classes: Classes that contain abstract methods are called abstract classes.||||||||| Abstract classes cannot be instantiated (new
All right, the parent class postparent is defined as abstract, which specifies that the subclass must re-implement the Buildhtml () method, which does not have curly braces, and if there are any content will be an error.
Now the more you see the code is not necessary to use abstract class, with inheritance is also very
PHP object-oriented programming advanced features (interface, inheritance, abstract class, destructor, clone, etc.), c abstract class destructor
This article describes the advanced features of PHP object-oriented programming. We will share this with you for your reference. The details are as follows:
Static attributes
(such as the Java Interpreter) runs a method, it first finds the method in the current class, then finds it in its superclass, and always looks up at the class level until the method is foundExamples of final methods:Class parent{public Parent () { }//constructor method final int getpi () {return math.pi;}//Finalization method}Description: GETPI () is a fi
Reprinted from http://hi.baidu.com/sjjqaa2010/blog/item/963bd13e0cdcadf33c6d974a.html
I. abstract classes
(1) abstract methods are declared only, but do not contain implementations. They can be considered as virtual methods without implementations.(2) abstract classes cannot be instantiated.(3) abstract classes
New Writing of the Python abstract class and the writing of the Python abstract class
I remember in the previous book learn python, because there was no official support at the time, I could only use the hack method to implement the abstract method. The simplest method is as
Class program {static void main (string [] ARGs) {display player = new screen (); player. in ("video"); player = new digital playback (); player. in (15); console. readline () ;}} abstract class displays {Where is Abstract Public void (object);} Class Screen: displays {publi
Python interfaceIn Python, there are two types of interfaces, one is the API interface that is accessed through a URL.One is an interface to an objectConstructing interfacesclassIjiekou:"""Defining a constraint interface""" defF1 (Self,nid):RaiseException ('All classes inheriting this interface class must implement (present) the F1 method')classoduixiang1 (Ijiekou):"""The F1 method is implemented by the inheriting interface.""" defF1 (Self, nid)
This article introduces the object-oriented abstract methods in PHP and the use of abstract class __call cloning objects, and friends who need to be able to learn.
Abstract methods and abstract classes
In the OOP language, a class
PHP abstract method and abstract class Abstracts keywordThe abstract keyword is used to define abstraction methods and abstract classes.
Abstract methods
Abstract methods are methods
Abstract methods and abstract classesIn OOP, a class can have one or more sub-classes, and each class has at least one public method as an external code to access its interface. Abstract methods are introduced to facilitate Inheritance. Let's take a look at the definitio
;}
Public Person (int age, string name ){
This. Age = age;This. Name = name; }
Public abstract void Say (); Public void Eat (){
Console. WriteLine ("I am a parent class ");}
}
Student class to inherit Person
public class Student:Person{ public Student(string name,int age){
Public Student (int age, string name): ba
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.