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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:39:05+00:00 2026-05-16T17:39:05+00:00

Here is my code – #include<iostream> using namespace std; class base { public: void

  • 0

Here is my code –

#include<iostream>
using namespace std;

class base
{
public:
    void sid()
    {
    }  
};

class derived : private base
{
public:
    void sid()
    {
    }
};

int main()
{
    base * ptr;
    ptr = new derived; // error: 'base' is an inaccessible base of 'derived'
    ptr->sid();
    return 0;
}

This gives a compile time error.

error: 'base' is an inaccessible base of 'derived'

Since the compiler will try and call the base class sid() why do I get this error? Can someone please explain this.

  • 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-16T17:39:05+00:00Added an answer on May 16, 2026 at 5:39 pm

    $11.2/4 states-

    A base class B of N is accessible at R, if

    • an invented public member of B would be a public member of N, or
    • R occurs in a member or friend of class N, and an invented public
      member of B would be a private or
      protected member of N, or
    • R occurs in a member or friend of a class P derived from N, and an
      invented public member of B would be a
      private or protected member of P, or
    • there exists a class S such that B is a base class of S accessible at R
      and S is a base class of N accessible
      at R.”

    Here ‘B’ is ‘Base’, ‘N’ is ‘Derived’ and ‘R’ is main.

    1. Consider the 2nd bullet- ‘R occurs in a member or friend of a class N,…’. This clause does not apply as ‘R'(main) is neither a member nor friend of ‘N'(Derived)

    2. Consider the 3rd bullet- ‘R occurs in a member or friend of a class P….’. This claus also does not apply for the same reasons as above

    3. Consider the 4th bullet- Once again this clause does not apply

    Thus we can conclude that ‘Base’ is not an accessible class of ‘Derived’.

    $11.2/5 states –

    If a base class is
    accessible, one can implicitly convert
    a pointer to a derived class to a
    pointer to that base class (4.10,
    4.11). [ Note: it follows that members and friends of a class X can
    implicitly convert an X* to a pointer
    to a private or protected immediate
    base class of X. —end note ]

    Since Base is not an accessible class of Derived when accessed in main, the Standard conversion from Derived class to Base class is ill-formed. Hence the error.

    EDIT 2:

    Study the error messages of some popular compilers and that should help you get a better understanding. Note how the word ‘inaccessible’ pops up so frequently and consistently across all the error messages

    The references are from the draft standard N3000. I am yet to download the latest draft 🙂

    GCC prog.cpp: In function ‘int
    main()’: prog.cpp:27: error: ‘base’ is
    an inaccessible base of ‘derived’

    Comeau Online “ComeauTest.c”, line 26:
    error: conversion to inaccessible base
    class “base” is not
    allowed
    ptr = new derived;

    VS2010 error C2243: ‘type cast’ :
    conversion from ‘derived *’ to ‘base
    *’ exists, but is inaccessible

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

Sidebar

Related Questions

here is code for regular expression matching #include<iostream> #include<stdio.h> #include<string.h> using namespace std; int
Here a code to demonstrate an annoying problem: class A { public: A(): m_b(1),
Here is code example class A{ int i; public: A(int i) : i(i) {}
I have following code: public class readSensorsData extends Activity implements SensorListener { /** Called
Here is code <h:outputLink styleClass=button value=javascript:void(0);> Text <f:ajax execute=@form event=click listener=#{commentView.saveComment} render=main_form /> </h:outputLink>
Here my code <a href=http://linkurl class=link title=sometitle> text link <span class=hidden-tooltip-data style=display: none;> <a
I have UiTextView where I want change font size (increase), here code -(void)biggerFont:(UIBarButtonItem *)
here code delegate void CheckNewsDelegate(); void CheckNews() { frmNews news = new frmNews(); news.Show();
The script is on jsfiddle here : CODE What it does at the moment
Ok the error is showing up somewhere in this here code if($error==false) { $query

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.