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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:44:51+00:00 2026-05-14T05:44:51+00:00

I have a class A which takes a reference of B in its constructor.

  • 0

I have a class A which takes a reference of B in its constructor.

 class A {
   public: 
     A(B& b); 
  }

And I have a class SubB which is a child class of B:

class SubB : public B {
    //omitted...
 }

In my code, I create a SubB and pass it to A:

   SubB subB; 
   A a(subB);

But I get this compile Error:

error: ‘B’ is an inaccessible base of ‘SubB’

Can I pass a reference of SubB as B?

Thank you.

  • 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-14T05:44:52+00:00Added an answer on May 14, 2026 at 5:44 am

    The posted code looks correct though declaration of class B is missing. Post more complete snippet – you problem is likely in misplacing include files and class declarations.

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

Sidebar

Related Questions

I have a base class( Base ) whose constructor takes a reference as argument.
I have an Assembly(A) which defines a Managed class which has a public constructor
I have a class which takes two arguments on it's constructor, an int and
I have FrameChangeAnimation class which takes multiple spritesheets and duration. So lets say I
I have a repository Class which takes in a ObjectContext called TestDB. I when
I have a class in C++ which takes an std::ostream as an argument in
I have a parameterized generic class X which takes a type T. On which
I have a Login Class which has a function: isCorrect() that takes username and
I have class which have one public method Start , one private method and
I have class Money which is an @Embeddable @Embeddable public class Money implements Serializable,

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.