Difference between Abstract Class and Concrete Class
Key Difference: There are two main types of classes: Abstract Class and Concrete Class. The main difference between the two arises from the level of implementation of their method functionalities. Concrete Classes are regular classes, where all methods are completely implemented. An abstract class is exactly what its name suggests. It is where the functions are not defined, i.e. they are abstract.
include("ad4th.php"); ?>Computers can be quite confusing, and that is before adding computer programming, programming languages, and protocols. Not to mention the fact that there are many different programming languages which are quite different from each other and have their own set of protocols. For example: object oriented programming (OOP) languages like Java and C# are very different than procedural programming languages and structural programming languages. OOP languages are class based, where as others are logic based. These OOP languages achieve the object oriented concepts such as encapsulation, inheritance and polymorphism through the use of classes.
There are two main types of classes: Abstract Class and Concrete Class. The main difference between the two arises from the level of implementation of their method functionalities. Concrete Classes are regular classes, where all methods are completely implemented. An abstract class is exactly what its name suggests. It is where the functions are not defined, i.e. they are abstract. It is the base class. Once an abstract class is defined, it ceases to be abstract and becomes a concrete class. A concrete class is where the implementations for the member functions are provided. A concrete class is derived from the base class, i.e. abstract class.
include("ad3rd.php"); ?>An abstract class is only made up of abstract methods. An abstract method only contains definitions, but no implementations. The implementations are provided in the concrete class, only after which the methods can be implemented. An abstract class can never be final, as it has no defined functions. Hence, each program must have a concrete class, in order to tell it which functions to implement and how.
An easier way to think about it would be to consider an example. Think of sports, it is an object, but one that doesn’t is not defined. Technically, there is no such thing as sport. It only exists as a categorization for other objects. These objects, such as football, baseball, basketball, hockey, etc. are defined objects that can be categorized and implemented under sports. Hence, sports is the abstract class, while football, baseball, basketball, and hockey are concrete classes.
Comparison between Abstract Class and Concrete Class:
|
Abstract Class |
Concrete Class |
Type |
Base class |
Default class |
Methods |
May contain partially implemented methods |
All methods are completely implemented |
Functions |
Some or all declared functions are purely virtual |
No purely virtual functions |
Instantiation |
Cannot be instantiated |
Can be instantiated |
Image Courtesy: tutorials.jenkov.com, stackoverflow.com
Add new comment