Jump to content

difference between using abstract and object inheritance


jibran3492

Recommended Posts

hi people,i want to know the difference between implementing abstract and extending an object(object inheritance) in php !according to what i know implementing abstract is using all code of parent class, and extending an object is also same including you can override a method...so if we have inheritance(i.e. extending an object) then why to use abstract ?

Edited by jibran3492
Link to comment
Share on other sites

Abstract objects and inheritance aren't mutually exclusive.

 

Inheritance is when a class extends from another one. An abstract class is just a class that doesn't represent any particular object you're going to create.

 

An example of abstract class would be Vehicle. You extend Car and Bike from Vehicle, but you never create a new Vehicle.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...