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 146039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:31:49+00:00 2026-05-11T08:31:49+00:00

I was reading on the sealed keyword in C#. I cant remember the last

  • 0

I was reading on the sealed keyword in C#. I cant remember the last time i inherit from a standard library. In c++ I remember inheriting an std interface that typedef a few types and used some of my parameters. But that is 1) Trivial 2) An interface

From the top of my head, i dont remember any class that i inherited that didnt have a virtual function expecting to be inherited. Can anyone tell me of a situation where you needed to inherit a non trivial class that wasnt an interface?

I might even say its a good rule to thumb not to inherit a class unless it has virtual functions. Is this a good rule of thumb?

NOTE: I use operator SomeClass& SomeClass() { return m_someClass; } in the case i need to pass my object as another class. It works well.

  • 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. 2026-05-11T08:31:50+00:00Added an answer on May 11, 2026 at 8:31 am

    It is actually used in C++, for all these not-is-a kinds of inheritance (eg. inheriting an implementation, mixins, boost::noncopyable, where you inherit from it and make your class noncopyable, boost::operators where you inherit from some class and it will add some operators to your class). Also, when doing metaprogramming with C++ types, inheriting from another type(s) is one of the simplest methods of composing types.

    Another case where you inherit from a class that doesn’t have virtual functions, but serves as ‘kind of’ an interface, is static polymorphism (techniques like CRTP, where class ConcreteA : BaseA). They don’t need the virtual functions, because everything is resolved at compile-time.

    However, if you want to treat your class runtime-polymorphically, you should really make at least one method virtual, and that would be the destructor. There are exceptions, but rare.

    Even when you have a polymorphic hierarchy, you sometimes derive from concrete classes. One example would be a SingleLineEdit deriving from TextEdit. However, this is a little dangerous, because it breaks encapsulation of the parent class (eg. its methods may expect some implementation details, and you must respect and preserve them in the subclass – which may be tricky, since they are implementation details that may change without notice in the next version etc.)

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

Sidebar

Related Questions

I am a newbie in C#.I am reading about Sealed keyword.I have got about
Reading from MSDN: A delegate is a type that references a method. Once a
Reading the docs, I'd expect $(#wrap2).remove(.error) to remove all .error elements from #wrap2 .
Reading through the other questions that are similar to mine, I see that most
Reading up on design patterns, and have found that there are 23(?) some-odd patterns
Reading the FTP RFC (RFC959), I notice some modes that I've never seen used,
Reading through wikipedia I came across the concept of Sprints in Agile development. From
Reading around Nokia forums, it seems that accessing the Cell ID and related information
reading the docs i see that the glGetTexImage2d() function has a 'type' parameter. The
Reading this question on importing ColorData from matlab, I was wondering if there is

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.