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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:37:48+00:00 2026-05-29T10:37:48+00:00

Follow-up question to this one . Basically, in the following code, why does the

  • 0

Follow-up question to this one.

Basically, in the following code, why does the compiler think that the B inside A<B> in Cs constructor refer to the (inaccessible) constructor of the B base class?

struct B{};

template <typename T>
struct A : private T{};

struct C : public A<B>{                                                                             
    C(A<B>);   // ERROR HERE
};

Live example on Ideone. Output:

prog.cpp:1:9: error: ‘struct B B::B’ is inaccessible
prog.cpp:7:7: error: within this context

Note that the same error pops up if you change the constructor argument to A<B*>, A<B&> or even A<const B>. Also note that three of MSVC10, GCC 4.7 and Clang 3.1 ToT will error out, so it must be something in the C++ spec. What is it?

  • 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-29T10:37:49+00:00Added an answer on May 29, 2026 at 10:37 am

    The standard allows injected class names to be less accessible than the original names. This is even mentioned in a note in §11.1/5, together with an example:

    [ Note: In a derived class, the lookup of a base class name will
    find the injected-class-name instead of the name of the base class in
    the scope in which it was declared. The injected-class-name might be
    less accessible than the name of the base class in the scope in which
    it was declared. —end note ]

    [ Example:

    class A { };
    class B : private A { };
    class C : public B {
      A *p; // error: injected-class-name A is inaccessible
      ::A *q; // OK
    };
    

    —end example ]

    Accessing A unqualified uses the injected name, which is not accessible because it comes from private inheritance. Accessing A qualified uses the declared name, which is accessible in the global scope.

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

Sidebar

Related Questions

This is like a follow-up question to this one . Basically what I'm doing
I have a follow up question to this one . Now that I have
This is a follow-up question to this one . Take a look at these
I have a follow-up question to this one . I created a new form,
This question is a follow on from this one ... I am binding to
This question is a follow up on one of my other questions, Can I
This is a follow-on question from the one I asked here . Can constraints
This is really a follow on question to a previous one , where I
This is a follow-up questions on a previous one . Consider this code, which
This is a more specific question to follow up on [another question that I

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.