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

  • Home
  • SEARCH
  • 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 4021516
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:21:41+00:00 2026-05-20T10:21:41+00:00

I haven’t yet worked out a specific case. But I am about to embark

  • 0

I haven’t yet worked out a specific case. But I am about to embark on writing some code that I feel will end up needing this; and so I wanted to know if:

  1. Two classes can friend each other; so that they can freely access the private
    and protected members of the other (I believe the answer is yes, and ofcourse I
    can simply try it out!). Any detailed references or other question links with answers
    are also very welcome. I am aware of forward declarations and include guard compiler
    pre-directives and their use. My questions are rather more related to the semantics
    of the C++ language in terms of what it can offer with regard to this possibility
    of mutual friendship and how to use it properly.
  2. Is this generally recommended? Do people employ this kind of design on a regular basis?
    Under what circumstances would this be a recommended design (preferably with some
    examples).
  • 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-20T10:21:42+00:00Added an answer on May 20, 2026 at 10:21 am

    You can have mutual friendship:

    class A {
        friend class B;
    };
    
    class B {
        friend class A;
    };
    

    Whether or not this makes sense depends entirely on the problem you are trying to solve. It definitely could make sense in certain circumstances.

    The only example from my current project that utilizes mutual friendship is a container implementation: the container class is a friend of its iterator class and vice versa.

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

Sidebar

Related Questions

Haven't seen anything about it here but it seems to solve one of the
I haven't actually done this yet, and maybe I don't need to, but it
Haven't seen anything, but I have seen that you can create albums in the
I haven't worked with Java in about 10 years, so it's very probable I'm
Haven't found a solution to this problem yet, have tried some things... I have
I haven't found this question, feel free to close if it's already up here.
I haven't worked for very large organizations and I've never worked for a company
I haven't found any references to apps that use a custom activity indicator --
I haven't found any documentation on this or seen this done before, but is
I haven't worked with SQL Reporting much, however I have been trying to get

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.