Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6856101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:50:32+00:00 2026-05-27T01:50:32+00:00

I need a class to inherit another class. I have a static function _init()

  • 0

I need a class to inherit another class. I have a static function _init() in the base class, and I don’t want that method to be inherited in the derived class. I tried the final keyword but it’s not working. What should I do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:50:33+00:00Added an answer on May 27, 2026 at 1:50 am

    You’re misunderstanding what final means.

    One of the foundation principles of OOP is that if a class is a subclass of another class, then that class gets all the functionality of the class it inherits from. You can’t inherit just some of the superclass functionality, it’s all or nothing.

    The reason for this is a bit tricky to get to grips with but once you do, you’ll realise that it makes sense. Namely, if a piece of code is able to process items of a particular class, then it must also be able to process any subclass of the item as well. If a subclass didn’t have all the functionality of its superclass, you couldn’t do that.

    For example, imagine you have a class that defines interfacing with a payment gateway. As all payment gateways are different, you couldn’t (or at least shouldn’t) implement a single class that can interface with any of the payment gateways that are available. But in general, payment gateways work in the same basic way. A request is sent, including a user’s credit card details and amount you want to debit from the card. The payment gateway responds with a message saying whether payment was authorized or not.

    You’d implement that kind of functionality with an abstract superclass that defines how you interface with payment gateways in general, then you’d create a subclass for each payment gateway you want to use (paypal, sagepay, whatever).

    As all these subclasses inherit from the same base class, you can be certain that they all implement certain methods, and you can send messages to those methods without worry. As long as the payment class you’re dealing with is a subclass of your abstract payment class, then everything should work.

    If one of the subclasses was able to not implement something from the abstract superclass, then you couldn’t be sure that sending a particular message to a subclass would work, or throw an exception. This would make inheritance rather pointless.

    Final in PHP (and indeed most OOP languages that implement it or similar concepts) means “This is the final implementation of this method. If a programmer subclasses me, then he can’t replace my final methods with his own implementation”. It doesn’t mean that the methods will not be available in the subclass, just that you can’t change them.

    If you really must remove functionality from a subclass, you can do it by overriding the superclass method and replacing it with an empty method (one that does nothing). But don’t do that, as it will cause problems of the type discussed above.

    Generally, if you run into situations where you have functionality in a superclass that you don’t need in a subclass, it’s a code smell that’s telling you that you might need to rethink your design.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class derived from Dictionary. I need this class to simulate a
I need a component/class that throttles execution of some method to maximum M calls
I have a class (class A) that is designed to be inherited by other
I have a Form named ScanFolder , and I need another Form, that needs
I need a class that works like this: >>> a=Foo() >>> b=Foo() >>> c=Foo()
I need B class to have a min priority queue of AToTime objects. AToTime
Using C#, I need a class called User that has a username, password, active
I need a base class for my DTO classes which will be used in
Ok, so I know you can't have objects in a static class but i
I have a class which inherit from DropCreateDatabaseIfModelChanges. public class SetupData : DropCreateDatabaseIfModelChanges<CyclingClubContext> {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.