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

  • SEARCH
  • Home
  • 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 8510843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:49:00+00:00 2026-06-11T03:49:00+00:00

Example: class IGui{ protected: virtual bool OnClicked(){return false;} virtual bool OnHover(){return false;} virtual bool

  • 0

Example:

class IGui{
  protected:
  virtual bool OnClicked(){return false;}
  virtual bool OnHover(){return false;}
  virtual bool OnScrollBarChange(){return false;}
  virtual bool OnTextChange(){return false;}

  ...

}

class IGuiButton: public IGui{
  protected:

  virtual bool OnClicked() = 0;
  virtual bool OnHover(){
    do stuff
    return true;}
  ...
}

The point is having a commom interface for all gui types that can be (where not all virtuals need to be overridden), and then provide a lite specialization for a button, but for the button, theres must be a override for the OnClicked..

Also, I think I should make the ones a button shouldnt override private( so use private inheritance, and use that fancy “using Base::Method;” for making the specific ones protected?

  • 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-06-11T03:49:02+00:00Added an answer on June 11, 2026 at 3:49 am

    There are multiple sides to the question. The first one is actually a quite interesting question:

    Can a derived class have a pure virtual method that is not pure in the base?

    The answer is yes, it can. With the expected (if you expected this to work) semantics: a type derived from the intermediate type must implement the virtual function not to be an abstract type. This leads to a curious circumstance, where the base is not abstract, but the derived type is… which will be surprising. Just for this, I would avoid this in a design.

    Should you mark as private the members that deriving types should not override?

    No, there is no reason or advantage to do that. Whether the member function is public, protected or private derived classes can override it. Any code that can call the functions through the base type will still be able to call it by casting to base. This leads to another strange thing in your design. The base class is filled with protected virtual functions, which means that they are accessible only by the derived type. This does not define an interface and cannot be used as such. If a function/class takes a reference to a IGui, or a IGuiButton it will not be able to do much, as there is no public interface. That basically means that noone will be able to call any of the events –unless you are also abusing friendship to provide access to the event handler, but you should avoid it.

    So what is a proper design?

    There are different alternatives. I’d recommend that before creating your own square wheel you look at those wheels that were invented in the past: look at different graphical frameworks and libraries and try to understand why they decided to design them as such. Look at the differences and try to determine what advantages/disadvantages they bring and which option matches your problem. UI is a domain where there is a lot of prior art, and chances are you will not design from scratch anything better than people in the field have done in the past –you might do it, but it is much easier to fall in the same pitfalls everyone else felt before.

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

Sidebar

Related Questions

Example class code: <?php class example { public function forExample() { return true; }
Simple class for example: class Foo { protected $_bar; public function setBar( $value )
I have the following example-class: public class MyClass<T> { public IList<T> GetAll() { return
Example: class MyRecursiveIteratorIterator extends RecursiveIteratorIterator{ public function current(){ echo 'START'; return parent::current(); } }
Example: class C { public: void operator =(int i) {} }; class SubC :
I have an example class containing two data points: public enum Sort { First,
Here is code example class A{ int i; public: A(int i) : i(i) {}
Given an example class: class Fred { public: Fred() { func = &Fred::fa; }
example: class Vendor_ClassName_Helper { CONST FIRST_OPTION = 1; CONST SECOND_OPTION = 2; public function
An Example: class SpecialButton { public SpecialButton(ButtonConfig conf, Method definedMethod) { button = new

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.