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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:04:47+00:00 2026-05-15T04:04:47+00:00

I was going over some sample questions for an upcoming test, and this question

  • 0

I was going over some sample questions for an upcoming test, and this question is totally confusing me.

Consider the following code:

class GraduateStudent : public Student 
{
  ...
};

If the word “public” is omitted, GraduateStudent uses private inheritance, which means which of the following?

  1. GraduateStudent objects may not use methods of Student.

  2. GraduateStudent does not have access to private objects of Student.

  3. No method of GraduateStudent may call a method of Student.

  4. Only const methods of GraduateStudent can call methods of Student.

  • 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-15T04:04:48+00:00Added an answer on May 15, 2026 at 4:04 am

    Although this is a bare homework-ish question, I’m going to answer it because it is a terrible question. I would almost consider it a trick question, and it doesn’t really make for a good test of knowledge.

    The answer is 2. GraduateStudent does not have access to private objects of Student., except that this has nothing at all to do with private inheritance. Point 2 would be true whether or not the public keyword were present, since derived classes never have access to the private members of their base classes, no matter how they inherit.

    Private inheritance means essentially two things (as opposed to public inheritance):

    1. All public methods of Student become private methods in GraduateStudent. That means that if, for example, Student has a public method foo(), then GraduateStudent has a private method foo().

    2. The base class is “inaccessible”, which means that polymorphism does not work. In layman’s terms, this means that if GraduateStudent inherits privately from Student, then you cannot treat a GraduateStudent* as if it were a Student* (or a GraduateStudent& as if it were a Student&).

    It’s possible that the author of the question also meant for point 1 to be a correct answer, but it is ambiguously worded. What does it mean that “GraduateStudent objects may not use methods of Student“? It’s possible that the intent is for this to mean that you cannot call methods inherited from Student on objects of type GraduateStudent, like I wrote in the first point above, but the GraduateStudent object itself, within its methods, can use methods of Student.

    For example:

    class Student {
      public: 
        void foo() {};
    };
    
    class GraduateStudent : Student {
      public: 
       void bar()
       {
         foo(); // Legal
       }
    };
    
    int main() {
      GraduateStudent g;
    
      g.bar(); // Legal
      g.foo(); // Illegal
    
      return 0;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.