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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:59:45+00:00 2026-06-03T06:59:45+00:00

I have a template, which adds a specific ability to a class: template <Class

  • 0

I have a template, which adds a specific ability to a class:

template <Class ReceiverOfAbility>
class Able : public ReceiverOfAbility, SomeOtherClass
{
...
}

Then I have a standard tree-like inheritance:

class Base
{};

class Derived1 : public Base
{};

class Derived2 : public Derived1
{};

...

But somewhere in the tree there is a “backwards branch”

class Derived2WithAbility : public Able<Derived2>
{};

Suppose I have:

 Base* basePointer = new DerivedWithAbility;

How can I cast basePointer to SomeOtherClass at runtime? dynamic_cast does not work. The problem is that there will be a lot of derived classes and I do not know in forward where in the tree does the class inherit the ability. I would need to search in the tree for the place where the inheritance from Able occurs.

Any ideas?

EDIT:

I tried to

dynamic_cast<SomeOtherClass*>(dynamic_cast<Derived2WithAbility*>(basePointer))

But I get:

error: ‘SomeOtherClass’ is an inaccessible base of ‘Derived2WithAbility’

Any Idea why?

  • 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-03T06:59:46+00:00Added an answer on June 3, 2026 at 6:59 am
    class Able : public ReceiverOfAbility, SomeOtherClass
    

    SomeOtherClass is a private base class of Able<whatever>. For dynamic_cast to work (i.e. to be able to cast to SomeOtherClass successfully), it must be a public base.

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

Sidebar

Related Questions

I have a file template.txt which contains the following: Hello ${something} I would like
I have a template like script type: text/template, id: list-template, ''' <div class=display> <div
I have a template class which defines operators, that works on the template parameters.
I have a template class which implements function: template<typename T> class Matrix { ...
I have template in which a button is created with a link using css,
Say I have a template which displays a view based on a property: {{#if
I have an e-mail template which is just a plain, static HTML page. I
I have a custom magento template which im trying to tweak and just have
something driver me crazy here i have a big HTML template which i can't
If I have a template as follows, which is used to create a button:

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.