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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:04:10+00:00 2026-06-17T09:04:10+00:00

I am an object-oriented programming enthusiast at a beginner level. I have encountered the

  • 0

I am an object-oriented programming enthusiast at a beginner level. I have encountered the following puzzle:

class A { 
}; 

class B { 
protected: 
    friend class A; 
};

class C { 
public: 
    friend class B; 
};

Referring to the sample code above, assuming the above classes had data members, what names of C’s members could be used in declarations of members of A?

  1. Only private members

  2. Only protected members

  3. All of C’s data members

  4. Only public members

  5. None of C’s data members*

My choice is answer 4 as friendship is not transitive. Therefore, A is a friend of B, but A is not a friend of C (even though B is a friend of C).
Is that correct thinking?

Also, my issue is that so far (in the tutorial) I’ve met exmaples in which friendship was declared like this:

class X { 
public: 
    friend class Y;
};

What is the difference if instead of the public specifier we use the protected one? Like that:

class X { 
protected: 
    friend class Y; 
};
  • 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-17T09:04:11+00:00Added an answer on June 17, 2026 at 9:04 am
    1. You are correct. Friendship is not transitive nor is it Inherited.
    2. It does not make any difference under what access specifier you put the friend declaration.

    As long as class A itself is not declared friend of class C. You cannot access any protected or private members of C in A.

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

Sidebar

Related Questions

I'm definitely beginner in PDO and object-oriented programming at all. class mysql { public
I'm new to object oriented programming. I have made a class with a static
I'm new of the Object Oriented Programming methods: I have a class MyClass1 as
Level: Beginner I'm doing my first steps in Object Oriented programming. The code is
For example in classic object oriented programming I might have a class School which
I'm new to object oriented programming in PHP. I included a class and called
I have a clue about Object Oriented Programming: I need to have a parent
I'm teaching a Python class on object-oriented programming and as I'm brushing up on
I'm trying to learn object oriented programming more clearer by creating a database class
I'm still learning about object oriented programming... I made my own simple button class

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.