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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:18:28+00:00 2026-05-13T13:18:28+00:00

I need to prevent a class from being derived from so I thought to

  • 0

I need to prevent a class from being derived from so I thought to myself, this is something that Boost is bound to have already done. I know they have a noncopyable, they must have a nonderivable…

Imagine my surprise when I couldn’t find it….

That got me thinking.. There must be a reason. Maybe it isn’t possible to do using templates..

I’m sure if it was easy it’s be in the boost libraries.

I know how to do it without using templates, i.e. using a base class with a private constructor i.e.

class ThatCantBeDerived;  // Forward reference

class _NonDeriv
{
    _NonDeriv() {}
    friend class ThatCantBeDerived;
};

class ThatCantBeDerived : virtual public _NonDeriv
{
public:
    ThatCantBeDerived() :
      _NonDeriv()
    {
    }
};

Or something like this..

Maybe it’s the forward reference that causes the problem, or maybe there isn’t a portable way to achieve it..

Either way, I’m not sure why it isn’t in boost..

Any ideas?

  • 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-13T13:18:29+00:00Added an answer on May 13, 2026 at 1:18 pm

    Under the current spec, it is explicitly forbidden to “friend” a template argument, so templatizing your example would make it not standards compliant. Boost probably would not want to add something like that to its libraries. I believe this restriction is being relaxed in Ox however, and there are workarounds for compilers.

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

Sidebar

Ask A Question

Stats

  • Questions 319k
  • Answers 319k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Note that if the files are supplied by users, your… May 14, 2026 at 12:13 am
  • Editorial Team
    Editorial Team added an answer You can create a new class which inherits the TreeNode.… May 14, 2026 at 12:13 am
  • Editorial Team
    Editorial Team added an answer This can be done as follows: Modify jqzoom1.0.1.js where the… May 14, 2026 at 12:13 am

Related Questions

We have a restriction that a class cannot act as a base-class for more
I have a collection of classes that inherit from an abstract class I created.
I have a C# app that needs to do a hot swap of a
Has anyone been able to successfully unit test methods that are, by necessity, coupled
I've created a factory assembly that can process any type of transaction (that supports

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.